Hi,
In my game I have a player object and if the player hits an “obstacle”, they get a transition.moveBy applied to them which moves them to the left like so:
transition.moveBy(thisPlayer, { x = -moveAmount, y = 0, time = moveXby.moveByTime })
I am trying to figure out what the best way is to check if they reached the left edge of the screen while the transition is being applied to them.
I have a function I call when a collision is registered which checks the player’s position like so:
local function playerReachedLeftEdge(player) if ((player.x - (player.contentWidth/2)) \<= display.screenOriginX) then -- apply transition to move player left return true else -- cancel all transitions on this player return false end end
3 scenarios can happen here:
- The player is nowhere near the left edge of the screen, moveby is fine
- The player is on the left edge of the screen therefore no moveby is called
- In the process of transitioning, they reach the left edge of the screen
How do I check for if the player reached the edge of the screen while the transition is being applied to them? I know I can use onStart to call a function but what logic do I put in the function?
Thanks in advance!
Ps. Also, what is the difference between transition.moveBy() and transition.to()?