Game Development Reference
In-Depth Information
public function get angle():Number {
return _angle;
public function set angle(value:Number):void {
_angle = value;
rotation = _angle * (180 / Math.PI);
public function get speed():Number {
return _speed;
public function set speed(value:Number):void {
_speed = Math.max(Math.min(value,maxSpeed),-
if (Math.abs(_speed)
stoppingThreshold) _speed = 0;
public function get acceleration():Number {
return _acceleration;
public function set acceleration(value:Number):void {
_acceleration = Math.max(Math.min(value,
The Time Class
Before we move on to the Game class, we should take a quick look
at a helpful utility class that will by the game. Since Flash is a
frame-based environment, and, therefore, is dependent on the
machine it is running on maintaining a consistent frame rate, it
good idea to have a way to enforce accuracy in our calculations
regardless of the number of frames actually being processed. It is
also often easier to think of units like speed and acceleration in
terms of seconds rather than frames. To gain this accuracy, we
need to know how much actual time has transpired between
frames.Thischangeintimeisoftenreferredtoas delta time .This
value can be obtained within a couple of lines using the getTimer
method in the flash.utils package. We could have just written these
lines into the Game class, but because it has so many applications,
s better to write it once in a class and reference it there from
now on.
Search Nedrilad ::

Custom Search