Trees | Indices | Toggle frames |
---|
Actions for moving things around based on their velocity and acceleration.
The simplest usage:
sprite = cocos.sprite.Sprite('ship.png') sprite.velocity = (100, 100) sprite.do(Move())
This will move the sprite (100, 100) pixels per second indefinitely.
Typically the sprite would be controlled by the user, so something like:
keys = <standard pyglet keyboard state handler> class MoveShip(Move): def step(self, dt): super(MoveShip, self).step(dt) self.target.dr = (keys[key.RIGHT] - keys[key.LEFT]) * 360 rotation = math.pi * self.target.rotation / 180.0 rotation_x = math.cos(-rotation) rotation_y = math.sin(-rotation) if keys[key.UP]: self.target.acceleration = (200 * rotation_x, 200 * rotation_y) ship.do(MoveShip())
Move
Move the target based on parameters on the target.
|
|
WrappedMove
Move the target but wrap position when it hits certain bounds.
|
|
BoundedMove
Move the target but limit position when it hits certain bounds.
|
|
Driver
Drive a CocosNode object around like a car in x, y according to
a direction and speed.
|
Trees | Indices | Toggle frames |
---|
Generated by Epydoc 3.0beta1 on Wed Sep 08 23:50:16 2010 | http://epydoc.sourceforge.net |