Game Development Reference
In-Depth Information
mouse events, so it will function in the same manner when being
run on a desktop machine.
public class Title extends Sprite
{
public var btnPlay:SimpleButton;
public var btnRules:SimpleButton;
public function Title()
{
addEventListener(Event.ADDED_TO_STAGE,
onAddedToStage, false, 0, true);
}
private function onAddedToStage( _evt:Event ):void
{
btnPlay.addEventListener(MouseEvent.CLICK,
onPlayClick, false, 0, true);
btnRules.addEventListener(MouseEvent.CLICK,
onRulesClick, false, 0, true);
}
private function onPlayClick( _evt:MouseEvent ):void
{
Main.getInstance().gotoAndStop(Main.FRAME_GAME);
}
private function onRulesClick( _evt:MouseEvent ):void
{
Main.getInstance().gotoAndStop(Main.FRAME_RULES);
}
}
Rules.as
This class is a little more involved. If you refer to the XFL docu-
ment and open the Rules clip from the library, you
ll see that there
are two screens of instructions, but only one is visible on stage.
The other is off to the right, but they are both contained in a single
display object called clipRulesText .We
'
'
ll use a combination of ges-
tures and TweenNano (the superlight version of TweenLite) to
simulate the popular swiping effect used in many iOS and Android
applications. There are other ways to have organized this content,
but for the sake of this example, this was the most straightforward.
import flash.events.TransformGestureEvent;
import com.greensock.TweenNano;
import com.greensock.easing.Quad;
Search Nedrilad ::




Custom Search