Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

Thanks!

share|improve this question
    
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? –  Jordaan Mylonas Sep 19 '11 at 3:43
    
what do you mean?? –  jan Sep 19 '11 at 15:08
1  
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 Mylonas Sep 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. –  Piku Jan 13 '12 at 11:59
    
"When the player gets past 150" -- 150 what? Pixels? Tiles? Enemies? –  Anko Mar 16 '12 at 8:29

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.