Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=======================================
- // FRAME 1
- //=======================================
- stop();
- Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;//need only 1 time!!
- menuplay.addEventListener(TouchEvent.TOUCH_TAP, playgame);
- function playgame(event:TouchEvent):void{
- //gotoAndPlay(2);//better only GOTO AND STOP..
- gotoAndStop(2);
- }
- //=======================================
- // FRAME 2
- //=======================================
- stop()
- //Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;//no need here too..
- //removeChild(menus);//no need remove we use VISIBLE!!
- //removeChild(backgame);//no need remove we use VISIBLE!!
- menus.visible = false;
- backgame.visible = false;
- var lompat = false;
- var loncat = 30;
- var gravitasi = 6;
- var batasAtas = 350;
- var playerScore: int = 0;
- var game_paused: Boolean = false; //@new
- pauseBT.addEventListener(TouchEvent.TOUCH_TAP, pause_menu);
- home.addEventListener(TouchEvent.TOUCH_TAP, home_menu);
- backgame.addEventListener(TouchEvent.TOUCH_TAP, remove_pause);
- tombol.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_4);//????
- addEventListener(Event.ENTER_FRAME, loop); //add loop
- //addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_2);//need only 1 loop(enterframe function)
- function pause_menu(event: TouchEvent): void {
- trace("btname:",event.target.name);//temp
- menus.visible = true; //visible AGAIN
- backgame.visible = true; //visible AGAIN
- //-------------------------
- pauseBT.visible=false;
- //-------------------------
- game_paused=true;
- //stage.frameRate = 0;
- player.stop();
- }
- function remove_pause(event: TouchEvent): void {
- trace("btname:",event.target.name);//temp
- //stage.frameRate = 24;
- //removeChild(menus);//no need //removeChild(backgame);//no need
- menus.visible = false;
- backgame.visible = false;
- //-------------------------
- game_paused=false;
- pauseBT.visible=true;
- player.play();
- }
- function home_menu(event: TouchEvent): void {
- trace("btname:",event.target.name);//temp
- //addChild(menus); //addChild(backgame); //-menus.visible = true; //visible AGAIN//--backgame.visible = true; //visible AGAIN
- //no need - all objects are position right, only invisble! //menus.x = 400; //menus.y = 240; //backgame.x = 410; //backgame.y = 200;
- removeEventListener(Event.ENTER_FRAME, loop); //remove loop - in first frame no use..
- gotoAndStop(1);
- //stage.frameRate = 0;
- }
- function fl_TapHandler_4(event: TouchEvent) {
- trace("btname:",event.target.name);//temp
- trace("testignaifwa")
- lompat = true;
- }
- function loop(event: Event): void {
- if (!game_paused) {
- if (lompat) {
- player.y -= loncat;
- loncat -= gravitasi;
- if (player.y > batasAtas) {
- //nilai variable melompat diubah menjadi false
- lompat = false;
- //nilai variable loncatan diubah menjadi 30 kembali
- loncat = 30;
- }
- }
- a.x -= 10;
- if (player.hitTestObject(a) == true) {
- playerScore += 10;
- updateTextFields();
- }
- } else {
- trace("game paused!");
- }
- }
- function updateTextFields(): void {
- playerScoreText.text = ("SCORE :" + playerScore);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement