How do you create a trajectory/falling player?

Hi,

Here is a screenshot of my game. I want the player to follow the outlined path. I am not using any physics, I was hoping I could achieve a close-enough gravity-like behaviour using easing. What I was hoping to do was to use  deltaPerFrame on the player object to make them move right and then use  transition.moveBy on the player object to make them go down using easing but I can’t seem to make those 2 actions work at the same time.

I am using enterFrame to continuously update the player’s deltaPerFrame in the x direction and I apply the moveBy transition once when the player collides with the cliff but what I am seeing is the moveBy transition runs first and then the deltaPerFrame kicks in after the moveBy transition is done even though I double checked that these two actions do happen at the same time. Does anyone know why that is? Can those 2 actions work at the same time?

In my observation, one can’t really combine transition.* with  enterFrame.  They are always a little out of sync.

You’d be better served doing all the calculations and movements for this scenario in enterFrame, of by using a temporary body and physics.

If you do decide to use transition, you’re going to need overlapping transitions to achieve that path.  You are aware you can call transition on an object multiple times in the same period, right?

Finally, I am not a big supporter of using anything but: transition.to() and transition.from()  I find using the other helper transition.* functions simply interferes with solving complex problems.  You can do everything you need with the two base functions.

If you need help figuring out the math for the path, take a look at this example and take the code that draws the trajectory:

https://github.com/roaminggamer/RG_FreeStuff/blob/master/AskEd/2017/01/PredictingTrajectory.zip

I am not the author of this code.

if you’re _ already _ using an enterFrame listener for x, then suggest you do same for y

fe here’s a very basic Euler integrator:

local car = display.newRect( 20, 50, 20, 10 ) car.vx = 10 -- x-velocity, assumed to be instantaneous (ie, is already in effect) car.vy = 0 -- y-velocity, none yet car.ax = 0 -- x-acceleration, none (x-velocity is assumed to be already in effect) car.ay = 1 -- y-acceleration, aka gravity car.enterFrame = function(self, event) -- integrate position self.x = self.x + self.vx self.y = self.y + self.vy -- integrate velocity self.vx = self.vx + self.ax self.vy = self.vy + self.ay end Runtime:addEventListener("enterFrame", car)

In my observation, one can’t really combine transition.* with  enterFrame.  They are always a little out of sync.

You’d be better served doing all the calculations and movements for this scenario in enterFrame, of by using a temporary body and physics.

If you do decide to use transition, you’re going to need overlapping transitions to achieve that path.  You are aware you can call transition on an object multiple times in the same period, right?

Finally, I am not a big supporter of using anything but: transition.to() and transition.from()  I find using the other helper transition.* functions simply interferes with solving complex problems.  You can do everything you need with the two base functions.

If you need help figuring out the math for the path, take a look at this example and take the code that draws the trajectory:

https://github.com/roaminggamer/RG_FreeStuff/blob/master/AskEd/2017/01/PredictingTrajectory.zip

I am not the author of this code.

if you’re _ already _ using an enterFrame listener for x, then suggest you do same for y

fe here’s a very basic Euler integrator:

local car = display.newRect( 20, 50, 20, 10 ) car.vx = 10 -- x-velocity, assumed to be instantaneous (ie, is already in effect) car.vy = 0 -- y-velocity, none yet car.ax = 0 -- x-acceleration, none (x-velocity is assumed to be already in effect) car.ay = 1 -- y-acceleration, aka gravity car.enterFrame = function(self, event) -- integrate position self.x = self.x + self.vx self.y = self.y + self.vy -- integrate velocity self.vx = self.vx + self.ax self.vy = self.vy + self.ay end Runtime:addEventListener("enterFrame", car)