Starling handbook Preview
Starling handbook Preview - Gamua, Starling Framework, Actionscript 3, AS3, Adobe AIR
Starling handbook Preview - Gamua, Starling Framework, Actionscript 3, AS3, Adobe AIR
Erfolgreiche ePaper selbst erstellen
Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.
Pivot Points<br />
<br />
The code also introduces the concept of pivot points. Per default, the root of an<br />
image is at the top left (just as the stage’s root is at the top left). Via the pivotX and<br />
pivotY properties, you can move that root (the pivot point) to a different location.<br />
Above, we are moving the pivot point to the center of the bird’s body, which has<br />
two advantages:<br />
1. Should we want to rotate the bird later, it will rotate around its center.<br />
2. It will simplify the collision detection code we need to write a little later.<br />
Run the project now to see the bird airborne!<br />
Figure 7. The bird is in the air.<br />
Something seems to be wrong, though: there is no flapping animation, just a static image!<br />
That’s because the MovieClip doesn’t have any information about the passage of time yet; and<br />
without that information, it will simply stick to the very first frame.<br />
In this case, we want to have full control over the bird’s animation, so we update it manually once<br />
per frame. Let’s do this by adding the following method to the World class:<br />
14