Hi there! 
I have a few buttons wich will apply different force to my character. Got that code working good by having an array with different force values, then I do this:
[lua]local function onTouch( event )
local touched = event.target --event.target is the button touched
if ( canjump == “true” and event.phase == “began” ) then
character:applyForce( touched.xForce, touched.yForce, stick.x, stick.y )
end
end
–and I got the listeners applied using a loop
for i=1,#touchObjects do
touchObjects[i]:addEventListener ( “touch”, onTouch )
end[/lua]
Works really good. However, now I want the charcter to keep jumping when button is pressed. I got the code for this using just a single button, and it works great, but how can I refernce the “touched.xForce” from outside of the onTouch function?
Here’s my continuous touch function
[lua]function movechar()
if ( canjump == “true” and touched == “yes” ) then
character:applyForce( 0, -580, stick.x, stick.y ) --THIS works fine
character:applyForce( touched.xForce, touched.yForce, stick.x, stick.y ) --THIS is not working since “touched” does not keep the value, returns nil.
elseif touched == false then
return false
end
end
local jumptimer
jumptimer = timer.performWithDelay(30, movechar, 0)[/lua]
So is there any work around for this?
All my best! [import]uid: 187595 topic_id: 32695 reply_id: 332695[/import]