As it said in the title, this is a bit weird.
I am trying to creating a function that when you tap a specific spot, an arrow appears. When the ball touches the arrow, the ball boosts and the arrow disappears.
But when I tap the scene in the simulator, the arrow doesn’t shows up in the spot where I tapped, it shows up in the bottom-right!
Typed the code myself. Maybe it’s because I’m not that experienced?
How can I make the image appear at the center of where I tapped?
Any help will be appreciated.
[code]
local function draw_liner(event)
if event.phase == “began” then
local blt = display.newImage( “blt.png”, event.x, event.y )
blt:setReferencePoint(CenterReferencePoint);
physics.addBody( blt, “static”, { isSensor = true } )
–Boost right function
local function onLocalCollisionbr( self, event )
if ( event.phase == “began” ) then
ball:applyLinearImpulse( 0.2, 0, ball.x, ball.y )
blt:removeSelf()
end
end
blt.collision = onLocalCollisionbr
blt:addEventListener( “collision”, blt )
return true
end
Runtime:addEventListener(“touch”, draw_liner) [import]uid: 44110 topic_id: 27227 reply_id: 327227[/import]