Some "controls" advice for a newbler?

Hey all, been working on getting some sort of game together, and I’ve found a few roadblocks as a corona noob I was wondering if I could pick some brains about here…

first, I coded up some nice buttons to control my character running, and jumping and was upset to find that multitouch doesn’t work on these button widgets, so if I was holding the run button down, I couldn’t jump…

So I recoded them all to use imageRect, and sprite images, and the outcome seems no different, I can’t jump if I’m running :stuck_out_tongue:

Also, the user can drag their finger out of the button, and they will continue to run, ie: no release is triggered if they drag out of the image area…

So… I added the “elseif event.phase == “moved” then”
but that triggers if they move their finger a little bit, not out of the image…

here is my code :

 goRightButton = display.newImage( imageSheet, 7 )  
 goRightButton.x, goRightButton.y = 110,300  
 local function goRightTouched( self, event )  
 if event.phase == "began" then  
 print('goright Touched')  
 walkRight()  
 elseif event.phase == "moved" then  
 print('goright released')  
 standRight()  
 elseif event.phase == "ended" or event.phase == "cancelled" then  
 print('goright released ')  
 standRight()  
 end  
 return true   
 end  
 goRightButton:addEventListener( "touch", goRightButton )  
 jumpButton = display.newImage( imageSheet, 11 )  
 jumpButton.x,jumpButton.y = 440,300  
  
 local function jumpTouched( self, event )  
 print('Jump released ')  
 ninjaJump()  
 return true -- IMPORTANT  
 end  
  
 jumpButton.tap = jumpTouched  
 jumpButton:addEventListener( "tap", jumpButton )  
  

basically, I’d like to user to be able to drag their finger across 2 buttons and have whichever their touch is inside be active… not as it is now, where the user must actually “press” or “release” the button…

is this possible ? it’s gotta be…
[import]uid: 157863 topic_id: 30516 reply_id: 330516[/import]

You have to activate multitouch for it to work, this is all you have to add first few lines of your page or depending on when you want it to be active only:

system.activate( "multitouch" )  

too tired to read the rest, will reply in the morning if no one else does sorry. good luck [import]uid: 77199 topic_id: 30516 reply_id: 122262[/import]

I couldn’t get widget buttons to support multitouch, not sure if they do now.

I changed my game to use ui.lua instead, very simular to the way you code the widget buttons but it does support multitouch.

For you other problem, you need to make a slight change to ui.lua, so that if a button is pressed and the finger is dragged off the button a release it still triggered.

Comment out lines 85 and 92, they should be -

85: if isWithinBounds then  
92: end  

Dave [import]uid: 117617 topic_id: 30516 reply_id: 122292[/import]

You have to activate multitouch for it to work, this is all you have to add first few lines of your page or depending on when you want it to be active only:

system.activate( "multitouch" )  

too tired to read the rest, will reply in the morning if no one else does sorry. good luck [import]uid: 77199 topic_id: 30516 reply_id: 122262[/import]

I couldn’t get widget buttons to support multitouch, not sure if they do now.

I changed my game to use ui.lua instead, very simular to the way you code the widget buttons but it does support multitouch.

For you other problem, you need to make a slight change to ui.lua, so that if a button is pressed and the finger is dragged off the button a release it still triggered.

Comment out lines 85 and 92, they should be -

85: if isWithinBounds then  
92: end  

Dave [import]uid: 117617 topic_id: 30516 reply_id: 122292[/import]