Context of the game:
As most of the plane fighter / arcade shoot em up games nowadays, the basic control is to swipe anywhere in the screen to move the plane character.
Summary of Issue:
The Plane character “teleports to the swiping position”
Things already done:
-
The design is to move the character by swiping anywhere on the screen. Most tutorials I’ve searched in Google is either Plane fighter with D-pad controller or the character should be dragged (event.target during run time)
-
I came across to this topic and gave it a try. < link>
Current code chunk:
local function f\_planeTouchEvent( im\_event ) if ( im\_event.phase == "began" ) then --Lets the program focus on the touched object display.getCurrentStage():setFocus( im\_event.target, im\_event.id) im\_event.target.isFocus = true --Store the original X and Y values of touched object im\_event.target.markX = im\_event.target.x im\_event.target.markY = im\_event.target.y elseif ( im\_event.phase == "moved" ) then --Object was moved/dragged if ( im\_event.target.isFocus ) then im\_event.target.x = im\_event.x im\_event.target.y = im\_event.y end end end --\< other codes of the program here \> ld\_s\_plane:addEventListener( "touch", f\_planeTouchEvent)
Simulation (please see attached image for visualization )
-
Start of simulation, image is at the bottom part
-
As I swipe the upper part, the plane character teleported to where I swiped.
Expected Outcome:
The plane should still be at the bottom part with movement imitating my swipe
Other information:
Corona SDK release: 2018.3326
Computer OS: Windows 10 64 bit
Simulation views encountered: All devices
Notes:
-Let me know if there are statements that are confusing in my post. Apologies as I am not a native English speaker.
-If there are things that I forgot to include, please let me know.
-If this is already solved from other post/sites. Please direct me. Maybe I am using the incorrect keywords