 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
MacorgaZ
Joined: 26 Jun 2006 Posts: 1
|
Posted: Mon Jun 26, 2006 12:43 am Post subject: [Controls help] Push the Up-button and the X button to... |
|
|
Hi!
I'm new here to the forum, so if I do anything wrong, just tell me :).
I want to make a simple game, and for that i need a piece of code that checks if 2 buttons are pressed, like the Up-button and the X-button.
Would this code do:
| Code: | if pad:cross() and
pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end
|
Or is there something wrong in it?
I'm just a beginner (a bit better then newbie :p), so I don't know how to use If-statements that wel.
So, if anybody knows how i should do this, please tell me :).
Thanks in advance, MacorgaZ. |
|
| Back to top |
|
 |
Debug
Joined: 06 Oct 2005 Posts: 16
|
Posted: Mon Jun 26, 2006 4:43 am Post subject: |
|
|
it should, try it, if not, try
| Code: |
if pad:cross() then
if pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end
end
|
_________________
| Code: |
catch(IOException e){
//oh crap
}
|
|
|
| Back to top |
|
 |
daurnimator

Joined: 11 Dec 2005 Posts: 38 Location: melbourne, australia
|
Posted: Wed Jun 28, 2006 11:09 pm Post subject: |
|
|
it should work...
have you tested it? |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Sat Jul 01, 2006 5:22 am Post subject: |
|
|
pad = controls.read()
| Code: |
if pad:cross() and
pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end
|
|
|
| Back to top |
|
 |
Teggles
Joined: 16 Jan 2006 Posts: 27
|
Posted: Mon Jul 10, 2006 7:43 am Post subject: |
|
|
If you would like the text to remain on the screen after pressing the buttons (then disappear after pressing again), you would use variables. Here is an example:
| Code: |
local display = 0
local pad = Controls.read()
while (true) do
pad = Controls.read()
if (pad:up()) and (pad:cross()) then
if (display == 0) then
display = 1
elseif (display == 1) then
display = 0
end
end
screen:clear()
if (display == 1) then
screen:print(0, 0, "blah", Color.new(0, 0, 0))
end
screen.flip()
end
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|