Game Development Reference
In-Depth Information
public function soundEventListener(e:CustomEventSound):void {
if (e.type == CustomEventSound.PLAY_SOUND) {
//trace("play sound");
soundManager.playSound(e.name, e.isSoundTrack, e.loops, e.offset, e.volume );
}else {
soundManager.stopSound(e.name, e.isSoundTrack);
}
}
public function keyDownListener(e:KeyboardEvent):void {
trace("key down: " + e.keyCode);
switch(e.keyCode) {
case KEY_PAUSE:
//pause key pressed
pausedKeyPressedHandler();
break;
case KEY_MUTE:
muteKeyPressedHandler();
break;
}
}
public function pausedScreenClickListener(e:Event):void {
removeChild(pausedScreen);
pausedScreen.removeEventListener(CustomEventButtonId.BUTTON_ID,
okButtonClickListener);
trace("clicked");
paused = false;
stage.focus = game;
}
public function pausedKeyPressedHandler():void {
trace("handle pause");
addChild(pausedScreen);
pausedScreen.addEventListener(CustomEventButtonId.BUTTON_ID ,
pausedScreenClickListener, false, 0, true);
paused = true;
}
public function muteKeyPressedHandler():void {
soundManager.muteSound();
}
}
}
That is the complete GameFrameWork.as file as it stands in this chapter. We will make many
additions to it when we cover preloading and Mochi integration in Chapter 12.
Search WWH ::




Custom Search