Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-21-2010, 09:25 AM   #1
Registered User
Join Date: Feb 2010
Posts: 3
Red face [AS3] Help with Side Scrolling Game


Im very new to Actionscript but we have been asked to create a side scrolling type game. Im having a little trouble with it, so if anyone could please help then that would be great.

Ive got a 'girl' walking/jumping over buildings and 'flying' monsters. What I need is for the monsters to stop flying when Game Over pops up. I also have a button that you can press to play again but the button doesnt stay on the screen it just flashes up then disapears. What I also need to 3 seperate movie clips for the girl, one for standing, one for walking (Which I have) and one for jumping and then I need them to alternate to the correct one when I use a right/left and up keys. Ill post all my code if thats ok and if anyone wants to see the fla file then I can add that too! Just any help would be great please, ive been struggling for ages with it.

ActionScript Code:
var _startmarker:startmarker;          var _girl_mc:girl_mc;          var _Boundaries:Boundaries;         var _monster:monster;                  var _vx:Number;          var _vy:Number;                                 _vx = 0;             _vy = 0;             _startmarker.visible = false;             gameOver.visible=false;                                 stage.focus = stage;                                 this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);             stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);             stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);                          function enterFrameHandler(e:Event):void         {                         _monster.x-=20;             if(_monster.x<0)             {_monster.x=2100;}                     playagain_btn.visible=false;                 if (_monster.hitTestObject(_girl_mc))         {                         gameOver.visible=true;             playagain_btn.visible=true;                                 playagain_btn.addEventListener(MouseEvent.CLICK, goplay);             function goplay(event:MouseEvent):void{             gotoAndStop(1); }                     }                         _vy += 2;                                     _girl_mc.x += _vx;             _girl_mc.y += _vy;                         processCollisions();                                                                             }          function keyDownHandler(e:KeyboardEvent):void         {             switch (e.keyCode)             {                 case 37:                 _vx = -7;                 break;                                 case 38:                 _vy = -20;                 break;                                 case 39:                 _vx = 7;                 break;                                 default:             }         }                  function keyUpHandler(e:KeyboardEvent):void         {             switch (e.keyCode)             {                 case 37:                 case 39:                 _vx = 0;                 break;                                 default:             }         }                                  function processCollisions():void         {                         if (_vy > 0)             {                                 if (_girl_mc.y > stage.stageHeight)                 {                     _girl_mc.x = _startmarker.x;                     _girl_mc.y = _startmarker.y;                     _Boundaries.x = 0;                     _Boundaries.y = 0;                     _vy = 0;                 }                                 else                 {                     var collision:Boolean = false;                                         if (_Boundaries.hitTestPoint(_girl_mc.x, _girl_mc.y, true))                     {                         collision = true;                     }                                         if (collision)                     {                         while (collision)                         {                             _girl_mc.y -= 0.1;                                                         collision = false;                                                         if (_Boundaries.hitTestPoint(_girl_mc.x, _girl_mc.y, true))                             {                                 collision = true;                             }                         }                                                 _vy = 0;                     }                 }                     scrollStage();                  function scrollStage():void         {             _Boundaries.x += (stage.stageWidth * 0.5) - _girl_mc.x;             _girl_mc.x = stage.stageWidth * 0.5;         }         }         }

Thank You again
lottielottie24 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 11:16 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.