multitouch issue with joystick

Hi,

I have an analogue joystick working great moving a craft around the screen, I have another object which is acting as a fire button.

The joystick is the mathew pringle one in the code exchange, this works fine using 2 sticks etc so the issue isnt there.

I have placed a tap event on the fire button, it is working fine.

However when I try to use the fire button and stick togethor, one or the other works.

Ok, so I think I have to give my tap event ID ? Iam a little confused as the best way to approach this.
I have read the below which I thought would throw me a lifeline, but It didnt help.
http://developer.coronalabs.com/forum/2012/03/31/multitouch-how-move-analog-joystick-and-press-button-same-time

So, what I am asking is how do I get both the touch and tap event working together?
here is my basic tap event code:

local fireButton = display.newCircle(410,260,24)  
fireButton:setFillColor (0,0,0,50)  
  
function fireButton:tap(event)  
 local bullet = display.newImage('images/bullet.png')  
 bullet.x = ship.x -10  
 bullet.y = ship.y -10  
 bullet.name = 'bullet'  
 physics.addBody(bullet)  
 bullets.insert(bullets, bullet)  
  
 end  
  
fireButton:addEventListener('tap',fireButton)  

Thanks for looking
[import]uid: 127675 topic_id: 32006 reply_id: 332006[/import]

use

[lua] syste.activate(‘multitouch’) --this will enable multi touch [/lua]

and always return true from you touch and tap listeners, so the events don’t get propogated. [import]uid: 113560 topic_id: 32006 reply_id: 127614[/import]

@dr2391 wrote:

 system.activate('multitouch') --this will enable multi touch   

Newb here btw.

Activating multitouch is certainly required, but there is more code needed.

bubblebobble, you are correct that you need a touchID, the event.id works great as the touchID to give the touch event it’s ID reference.

I don’t use a “tap” event, but use a “touch” event as I call the different event phases in each function that may be used in a multiTouch scenario like the dual sticks. You don’t need to add a touchID to touch events that don’t require multiTouch capability. “Tap” may work for your event, but I know “touch” does work.

Try something like this …

local fireButton = display.newCircle(410,260,24)  
fireButton:setFillColor (0,0,0,50)  
   
function fireButton:touch(event)  
 if event.phase == "began" then   
 display.getCurrentStage():setFocus( self ,event.id )   
   
 local bullet = display.newImage('images/bullet.png')  
 bullet.x = ship.x -10  
 bullet.y = ship.y -10  
 bullet.name = 'bullet'  
 physics.addBody(bullet)  
 bullets.insert(bullets, bullet)  
  
 elseif event.phase == "cancelled" or event.phase == "ended" then  
  
 display.getCurrentStage():setFocus( self ,nil )   
 end  
   
fireButton:addEventListener('touch",fireButton)  

Not sure this is exactly what you need, but it should point you in a direction that should work.

Hope this helps,

Nail
[import]uid: 106779 topic_id: 32006 reply_id: 127618[/import]

use

[lua] syste.activate(‘multitouch’) --this will enable multi touch [/lua]

and always return true from you touch and tap listeners, so the events don’t get propogated. [import]uid: 113560 topic_id: 32006 reply_id: 127614[/import]

@dr2391 wrote:

 system.activate('multitouch') --this will enable multi touch   

Newb here btw.

Activating multitouch is certainly required, but there is more code needed.

bubblebobble, you are correct that you need a touchID, the event.id works great as the touchID to give the touch event it’s ID reference.

I don’t use a “tap” event, but use a “touch” event as I call the different event phases in each function that may be used in a multiTouch scenario like the dual sticks. You don’t need to add a touchID to touch events that don’t require multiTouch capability. “Tap” may work for your event, but I know “touch” does work.

Try something like this …

local fireButton = display.newCircle(410,260,24)  
fireButton:setFillColor (0,0,0,50)  
   
function fireButton:touch(event)  
 if event.phase == "began" then   
 display.getCurrentStage():setFocus( self ,event.id )   
   
 local bullet = display.newImage('images/bullet.png')  
 bullet.x = ship.x -10  
 bullet.y = ship.y -10  
 bullet.name = 'bullet'  
 physics.addBody(bullet)  
 bullets.insert(bullets, bullet)  
  
 elseif event.phase == "cancelled" or event.phase == "ended" then  
  
 display.getCurrentStage():setFocus( self ,nil )   
 end  
   
fireButton:addEventListener('touch",fireButton)  

Not sure this is exactly what you need, but it should point you in a direction that should work.

Hope this helps,

Nail
[import]uid: 106779 topic_id: 32006 reply_id: 127618[/import]