On Sat, Jun 20, 2009 at 4:50 AM, jaber <[email protected]> wrote:

>
>
>
> On Jun 20, 2:50 pm, claudio canepa <[email protected]> wrote:
> When zooming in, it seems to zoom towards the center anchor of the
> layer regardless where has the camera been. Any workaround?
>
> Also, how do I make the camera follows a player sprite regardless how
> much the player zoom?
>

 The zoom ( and rotation ) center is in
world_layer.transform_anchor_x ,  world_layer.transform_anchor_y
you can adjust to suit your needs.


if you want the player show at the window's center,   add this method to
world_layer:
def update_camera_pos(self, (center_x,center_y)):
      x, y = director.get_window_size()
      self.x = -center_x + x/2
      self.y = -center_y + y/2

Then if your player is something like
player = MySprite(...)
player.position = initial_x,initial_y

where MySprite is subclass of Sprite with an update method like

(pseudocode!!)
def update(self,dt):
    self.position += dt*vel
    self.parent.update_camera_pos(self.position) # the player sprite must be
child of world_layer, or you must adapt to use Cocosnode.get_ancestor()

Note that zoom dont changes the player update.

--
Claudio

--~--~---------~--~----~------------~-------~--~----~
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