Sorry Daniel, somehow missed your response. At this exact moment, my code is nowhere near presentable but I can certainly tell you how I was able to accomplish through a means that worked for me.
Like any other movement, I’ve found it easiest to move all objects in relation to the player.
One thing to not about my project is that I want keep my characters y-axis value constant throughout the game. After I first initialize the character, I give it a value for “startY” which equals it’s starting y value.
[lua]player.startY = player.y [/lua]
Then I have a method run every frame called “updateYAxis” that would look something like this:
[lua]–check if player exists
if (player) then
–check if player has fallen
if player.y > player.startY then
–calculate the amount the player has fallen
–in my project I found it easier to round this by using math.floor
–math.floor is optional though, depending on what you’re doing.
yDiff = player.y - player.startY
–assuming you are keeping all of your objects in an array,
–move everything in the array the amount that the player fell
for i = 1, objectArray.numChildren do
objectArray[i].y = y - yDiff
end
end
end[/lua]
Now if you aren’t keeping your player at a static y coordinate you would want to add additional logic to update his “startY” value at the appropriate time.
Feel free to e-mail me with any questions. I’m by no means an expert but this is just one way I found to do this that seems to be what I needed.
tonyjlunt[at]gmail.com [import]uid: 172008 topic_id: 32848 reply_id: 131670[/import]