I was making a game and I did the side scrolling like this: if the player get past 150, the player stops moving and the background starts moving. But thats very annoying with placing objects in the game. Isn't there a better way to do this? I do not want to use cocos2D.

So, the player is standing still and the background moves instead, then the player can be said to always be at origin point (0,0). So, if you wanted to place an enemy 50 units ahead of the player, you place them at (50,0). However, if you wanted to place them at an absolute world positions, then you'd ant to place them relative to the background's position (since it's been moving backwards the entire time, its position is indicative of how far into the level the player is), so, you'd write a function such as: GetAbsolutePos(x,y){absX = x-background.x; ...}. That way, you can do either.
–
Jordaan MylonasSep 19 '11 at 20:45

@JordaanMylonas your comment is useful, you should write it up an an answer. I did a very similar thing in a game I wrote and it worked pretty well.
–
PikuJan 13 '12 at 11:59

1 Answer
1

Why not just have a utility function to get a "absolute" position from a given "player-relative" position, and have the best of both worlds?

So, the player is standing still and the background moves instead, then the player can be said to always be at origin point (0,0). So, if you wanted to place an enemy 50 units ahead of the player, you place them at (50,0). However, if you wanted to place them at an absolute world positions, then you'd want to place them relative to the background's position (since it's been moving backwards the entire time, its position is indicative of how far into the level the player is), so, you'd write a function such as: GetAbsolutePos(x,y){absX = x-background.x; ...}. That way, you can do either.