The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 1:59 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 6 posts ] 
[QUESTION]AS2 I don't know why Mario isn't... 
Author Message
User avatar

Joined: Mon Aug 11, 2008 10:37 am
Posts: 234
Location: ¯\(°_o)/¯
Gender: Male
Here's the file:
mariogameattemptCS3.fla - 0.72MB

I just started using Flash about a week or two ago, and I'm trying to put together a really easy Mario game for practice. I looked at x2i's tutorials for movement, and kind of spliced some of his code with another code I found on a youtube video(for jumping, since Dan's code didn't work for me there.) Right now, I'm stuck on how to get Mario to play the jumping animation from when he's jumping while standing, and jumping while running. I need some help, here's the code I put on Mario's MC:
Code:
onClipEvent (load) {
 idle = true;
 speed=5;
 gravity=0;
 r=_height/2;
 jumping = false;
 jumpheight=10;
}
 
onClipEvent (enterFrame) {
 
  if ((Key.isDown(Key.LEFT) && Key.isDown(Key.RIGHT)) || (!Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT))) {
    // If both keys are up or down he is standing
    idle = true; gotoAndPlay("stance");
 
  } else if (Key.isDown(Key.LEFT) && idle == true) {
    // Otherwise if the left key is down run left
    gotoAndPlay("walk");
   mario_mc._x -= 5;
    idle = false;
   _xscale = -100;
 
  } else if (Key.isDown(Key.RIGHT) && idle == true) {
    // Otherwise if the right key is down run right
    gotoAndPlay("walk");
   mario_mc._x += 5;
    idle = false;
   _xscale = 100;
  }
  if(Key.isDown(KEY.UP) && !jumping){
      gravity = -jumpheight;
      jumping = true;
      gotoAndPlay("jump");
  } else if (Key.isDown(Key.LEFT) && jumping == true) {
    // Otherwise if the left key is down run left
    gotoAndPlay("jump");
   mario_mc._x -= 5;
    idle = false;
   _xscale = -100;
  } else if (Key.isDown(Key.RIGHT) && jumping == true) {
    // Otherwise if the left key is down run left
    gotoAndPlay("jump");
   mario_mc._x += 5;
    idle = false;
   _xscale = 100;
  }
   if(!_root.ground.hitTest(_x,_y, true)){
      gravity++;
      _y +=gravity;
   } else {
      jumping = false;
      gravity = 0;
   }
   while (_root.ground.hitTest(_x,_y-1+r, true)) {
      jumping = false;
      _y--;
   }
}

                                       
   
   

And here's the code I put on the first frame of the whole scene(I would like to erase it, since it makes the game seem messy. But when I do try erasing it, in spite of putting the same code on Mario's MC, keypresses register and make the animation play, but won't move him left, right, or up anymore):
Code:
mario_mc.onEnterFrame = function(){

if(Key.isDown(Key.RIGHT)){

mario_mc.gotoAndPlay("walk")

mario_mc._x += 5

}

if(Key.isDown(Key.DOWN)){

mario_mc.gotoAndPlay("duck");

}

if(Key.isDown(Key.LEFT)){

mario_mc.gotoAndPlay("walk")

mario_mc._x -= 5

}

if(Key.isDown(Key.SPACE)){

mario_mc.gotAndPlay("jump");

}

}



The answer's probably really simple, but I'll learn from it no doubt. Thanks in advance!


Last edited by Brave_Shyguy on Tue Nov 30, 2010 6:13 am, edited 1 time in total.



Mon Nov 29, 2010 6:04 pm
WWW
User avatar

Joined: Fri Jan 02, 2009 6:02 pm
Posts: 7283
Location: Australia
Country: Australia (au)
Gender: Male
MGN Username: Tid
Currently Playing: Deep™ The™ Game™
Um, it may just be me but that looks a LOT like AS2, not 3.

_________________
ImageImageImageImage
Ask me anything!!!
Special thanks to Steven for my beautiful Deep avatar! <3


Tue Nov 30, 2010 1:08 am
WWW
User avatar

Joined: Mon Aug 11, 2008 10:37 am
Posts: 234
Location: ¯\(°_o)/¯
Gender: Male
Well, that just goes to show you my inexperience. The document I created was an AS3 document, but I guess there's a sort of backwards compatibility with AS2 code. I'll amend the title, thanks!


Tue Nov 30, 2010 6:12 am
WWW
User avatar

Joined: Fri Jan 02, 2009 6:02 pm
Posts: 7283
Location: Australia
Country: Australia (au)
Gender: Male
MGN Username: Tid
Currently Playing: Deep™ The™ Game™
The problem is probably that :/
Try doing it in an AS2 document and see if the results are favourable.

_________________
ImageImageImageImage
Ask me anything!!!
Special thanks to Steven for my beautiful Deep avatar! <3


Wed Dec 01, 2010 8:19 am
WWW
User avatar

Joined: Mon Aug 11, 2008 10:37 am
Posts: 234
Location: ¯\(°_o)/¯
Gender: Male
I copied the whole thing piece by piece into a new AS2 Flash Document, but there's no change.
mariogametryinCS2.fla - 0.72MB
:(


Thu Dec 02, 2010 6:27 pm
WWW

Joined: Sun Jun 13, 2010 10:41 pm
Posts: 21
Gender: Anime Girl
The reason why is because

you said in the code to "stand" if im not pressing any keys, and you holding the jump so
the animations goes back to the sand and jump repeating MAKING HIM FREEZE
stop that using a var saying
when he on the ground make var "onground"
and not tell the onground = false
then
if (onground){
"stand"
}
if (!onground){
"jump"
}


Fri Jan 21, 2011 9:29 pm
Display posts from previous:  Sort by  
 [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.