Hi, im making a game where you can shot arrows horizontally.
I’m using physics to detect the collition between the arrow and the target.
I want to make it so wherever you touch, the arrow goes to that point and continues flying until some time when it gets deleted, but im having some problems doing that.
This is what i got:
local arrow = {} local function shoot\_arrow(event) if event.phase == "began" then for i = 1,1 do arrow[i] = display.newImage("arrow.jpg") arrow[i].x = 0; arrow[i].y = 150 physics.addBody(arrow[i],"static",{ friction=0, bounce=0 } ) if event.y \>= 220 then arrow[i]:rotate(15) end if event.y \<= 140 then arrow[i]:rotate(-15) end transition.to(arrow[i],{x=event.x, y=event.y}) end end background:addEventListener("touch",shoot\_arrow)
The problem here is:
-
transition.to asigns a default time and if i touch the screen near the spawn area, it goes really slow until that point, and if i press it far from it, its speed is really fast. I tried other ways to replace transition or make the time dynamic but i couldn’t do it.
-
The arrow goes to event.x and event.y but stops there, tried with some onComplete functions but I couldn’t do it either.
Im not able to achieve this, can i get some help?
Thanks in advance!