On Sat, Jun 13, 2009 at 4:51 AM, cjung89<[email protected]> wrote:
>
> Is there a simple way of moving the camera around as in a sidescroller
> or a asteroids type game, with the camera fixed on the player?  A code
> example would be useful.  Say I just wanted to move the camera down 5
> pixels.  How would this be accomplished?

What i do is have the following nodes:

The scene node, where i add the map.
The map node, where i add the elements in the map. added to the scene.
The player node, added to the map.
The extra elements, added to the map.

Something like this:

scene = Scene()
map = CocosNode()
player = Sprite("player.png")
bg = Sprite("bg.png")
scene.add(map)
map.add(bg, z=-1)
map.add(player)

Then, every time i move the player, i move the map. For example, to
move the player 5 units to the left and still have it centered, i do:

player.x -= 5
map.x += 5

Same for y.

Lucio

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to