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 5:37 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.



 [ 8 posts ] 
[Tutorial]Fix game animations-Blade Hedgehog Engine Provided 
Author Message
User avatar

Joined: Mon Jul 06, 2009 11:54 am
Posts: 57
Gender: Male
I will try my best not to make this confusing for early beginners
Well I'm not really good with these things but I just wanted to help out a few people who might have some sort of confusion when trying to get there animations right in a simple platform game!
Well you see first of all when you are using a code like this:
Code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._xscale = 100;
this._x += 10;
this.gotoAndStop(2);
}
if (Key.isDown(Key.LEFT)) {
this._xscale = -100;
this._x -= 10;
this.gotoAndStop(2);
}
if (!Key.isDown(Key.LEFT) and (!Key.isDown(Key.RIGHT))) {
this.gotoAndStop(1);
}
}
onClipEvent (load) {
   //Sets the initial speed and downwards pull
   gravity = 5;
   speed = 5;
   isJump = true;
}
onClipEvent (enterFrame) {
   //Moves the player up or down
   gravity++;
   _y += gravity;
   //Keys to move left and right
   if (Key.isDown(Key.LEFT)) {
      _x -= speed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
   }
   //Check whether the character is already jumping
   //If not then jump
   if (Key.isDown(Key.UP) && isJump == false) {
      isJump = true;
      _y -= 5;
      gravity = -13;
   }
}

You have to make sure that when you put your animations in a movie clip and using this
Code:
gotoAndStop(insert frame here);

That Each Different Animation Inside The Movie Clip Should Have
Code:
stop();

Now you might be getting a little confused so i will provide some pictures for you.
Here We Have Our Main Movie Clip:
http://i40.tinypic.com/xlgex0.jpg

And Inside The Movie Clip We Have Two Frames.
And Each Frame Contains A Certain Kind Of Animations with both frames having
Code:
stop();
on the frame actions!
Now what i think confuses people is that they get all of the animations they want and just put them inside the one movie clip and then they put
Code:
gotoAndStop(insert frame here);
thinking that its going to work when it actually freezes the animations and only plays when you let the left or right key go.
Now is that the right way to do it?
NO ITS WRONG! NO COOKIES FOR U

You see inside the main movie clip you need to take the first sprite in the first frame and convert it into another movie clip!
(give it any name you want for its mc name)*buy for now well call it MC ANIM 1
http://i40.tinypic.com/1z3qs9e.png

And What you do then is you put all of the animations inside that movie clip!
**note do not put stop on these frames *inside MC ANIM 1, just put them in and leave it alone*
Once done that click back on the mc inside main movie clip that has to two frames with the
Code:
stop();
on it
and do the same thing for the second frame!(insert the first sprite for the running animation and make it a movie clip*call it whatever you want*
And Put all of your running sprites in there!*once done go back to the mc inside main movie clip again.
And Once Done That Take This Code Right Here*btw i posted it above to*
Code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._xscale = 100;
this._x += 10;
this.gotoAndStop(2);
}
if (Key.isDown(Key.LEFT)) {
this._xscale = -100;
this._x -= 10;
this.gotoAndStop(2);
}
if (!Key.isDown(Key.LEFT) and (!Key.isDown(Key.RIGHT))) {
this.gotoAndStop(1);
}
}
onClipEvent (load) {
   //Sets the initial speed and downwards pull
   gravity = 5;
   speed = 5;
   isJump = true;
}
onClipEvent (enterFrame) {
   //Moves the player up or down
   gravity++;
   _y += gravity;
   //Keys to move left and right
   if (Key.isDown(Key.LEFT)) {
      _x -= speed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
   }
   //Check whether the character is already jumping
   //If not then jump
   if (Key.isDown(Key.UP) && isJump == false) {
      isJump = true;
      _y -= 5;
      gravity = -13;
   }
}
And Put it inside The Main movie Clip !*which is also known as scene 1*
http://i39.tinypic.com/24qqr03.png
And When You Move the animations will be fixed!

Now if you dont know how to make a simple platform just make a rectangle or something, convert it to a movie clip!
Then double click the platform you just made and add this inside it;s first frame!
[code]onEnterFrame = function () {
   // Check whether platform has been landed on
   while (hitTest(_root.player._x, _root.player._y, true)) {
      // Stop player and allow him to jump again
      _root.player.isJump = false;
      _root.player.gravity = 0;
      _root.player._y--;
   }
};

*note where it says PLAYER you need to make the instance name of your character a player*
Thx for reading and here's an example of An Early Blade hedgehog Test Movement Engine I Made!
Press left arrow key for running, right arrow key for running, up arrow key to jump *note haven't added an jumping animation yet*
Oh and hold shift + and arrow key left or right to run faster.

And Here's What It Should Look Like!
http://www.newgrounds.com/dump/item/0ce ... 8e5a9dba46

And Here's A Copy Of The .fla File for you to use!
http://www.newgrounds.com/dump/item/e25 ... bc7e1d2398
*note i had my own custom vcam that was used to follow the player and have the background stay in the same position*
And I really don't feel like providing the link to my vcam or giving a code to the commands to follow the player right now because its 2:08 where i live and i need to get up at 7:00 a.m. in the morning to get ready for high school.*although there is a topic somewhere in this section where x2i provided a link to it)
Thanks for reading and I am very glad to help! :3 And If you need any more help or you want comment or provide any suggestions feel free to post in this topic ^_^
Oh and i still need help on making simple hit test walls because mine don't seem to work xD

_________________
Best Website's For Mugen Characters
http://www.mugencharacters.ucoz.com
& http://mugeninvasion.ucoz.com/load/3-1-0-6
ImageImageImage
My Youtube: http://www.youtube.com/reashun14
I PLAY COMBAT ARMS ONLINE!
Image


Mon Apr 05, 2010 2:11 am
WWW
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
if this was to help me thanks but this isnt really what i meant for my problem

and try using this tutorial for the walls you have
http://www.kirupa.com/developer/mx2004/platform_game3.htm

also you character still runs or stands while he is still in the air
if you have a jumping animation you could put

if (Key.isDown(Key.UP) && isJump == false) {
isJump = true;
this.gotoAndStop("jump")
//or whatever frame your jump is on
_y -= 5;
gravity = -13;
}

tell me if this helps any


Wed Apr 14, 2010 2:00 pm
User avatar

Joined: Mon Jul 06, 2009 11:54 am
Posts: 57
Gender: Male
jgillotti1352 wrote:
if this was to help me thanks but this isnt really what i meant for my problem

and try using this tutorial for the walls you have
http://www.kirupa.com/developer/mx2004/platform_game3.htm

also you character still runs or stands while he is still in the air
if you have a jumping animation you could put

if (Key.isDown(Key.UP) && isJump == false) {
isJump = true;
this.gotoAndStop("jump")
//or whatever frame your jump is on
_y -= 5;
gravity = -13;
}

tell me if this helps any


You see thats the thing about it, i tried that so many times but for some reason it never went right.
But I will try it again

_________________
Best Website's For Mugen Characters
http://www.mugencharacters.ucoz.com
& http://mugeninvasion.ucoz.com/load/3-1-0-6
ImageImageImage
My Youtube: http://www.youtube.com/reashun14
I PLAY COMBAT ARMS ONLINE!
Image


Wed Apr 14, 2010 11:44 pm
WWW
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
Reashaun14 wrote:

You see thats the thing about it, i tried that so many times but for some reason it never went right.
But I will try it again

if you have the jump animation i can see what i can do with it
i fixed the coding for you

this is for the character

Code:
onClipEvent (enterFrame) {
   if (Key.isDown(Key.RIGHT)) {
      this._xscale = 100;
      this._x += 10;
      this.gotoAndStop(2);
   }
   if (Key.isDown(Key.LEFT)) {
      this._xscale = -100;
      this._x -= 10;
      this.gotoAndStop(2);
   }
   if (!Key.isDown(Key.LEFT) and (!Key.isDown(Key.RIGHT))) {
      this.gotoAndStop(1);
   }
}
onClipEvent (load) {
   //Sets the initial speed and downwards pull
   gravity = 15;
   speed = 5;
   isJump = true;
}
onClipEvent (enterFrame) {
   //Moves the player up or down
   gravity++;
   _y += gravity;
   //Keys to move left and right
   if (Key.isDown(Key.LEFT)) {
      _x -= speed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
   }
   //Check whether the character is already jumping
   //If not then jump
   if (Key.isDown(Key.UP) && isJump == false) {
      isJump = true;
      _y -= 5;
      gravity = -13;
   }
   if (isJump == true){
      this.gotoAndStop(3)
   }
}


and this is for the left wall

Code:
onClipEvent (enterFrame) {
   if (this.hitTest(_root.player)) {
      _root.player._x += 10;
      _root.player.speed =  0
   }
}


just change the + to a - for the right wall
dont forget to add a jump animation on frame 3 for blade

_________________
get free wii points here!


Thu Apr 15, 2010 1:15 pm
User avatar

Joined: Mon Jul 06, 2009 11:54 am
Posts: 57
Gender: Male
Hey thanks the walls worked!
But about the jumping animation i did everything right but it still freezes on the first frame of the animation.

http://www.newgrounds.com/dump/item/c17 ... 08cd8d7bac

*added a tails chao mc that follows you
*added non passable walls this time
*added a nice SA2 insturmental
-Edit: I forgot to loop the music my bad

After This I will start making enemies/ platforms/ and more.
Image

_________________
Best Website's For Mugen Characters
http://www.mugencharacters.ucoz.com
& http://mugeninvasion.ucoz.com/load/3-1-0-6
ImageImageImage
My Youtube: http://www.youtube.com/reashun14
I PLAY COMBAT ARMS ONLINE!
Image


Thu Apr 15, 2010 11:50 pm
WWW
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
i would have to say its better now except the chao stops you from going farther at the left wall
is it part of the player?
this site might help

_________________
get free wii points here!


Fri Apr 16, 2010 12:14 pm
User avatar

Joined: Mon Jul 06, 2009 11:54 am
Posts: 57
Gender: Male
jgillotti1352 wrote:
i would have to say its better now except the chao stops you from going farther at the left wall
is it part of the player?
this site might help

Oh well u see that was on accident when i was coding xD
I fixed it but didnt feel like re uploading.
And i allready use that site for some of the stuff.
I dont really like that part of newgrounds tutorial section, I like as2 main.
But im coding right now and working on lots of other stuff.

_________________
Best Website's For Mugen Characters
http://www.mugencharacters.ucoz.com
& http://mugeninvasion.ucoz.com/load/3-1-0-6
ImageImageImage
My Youtube: http://www.youtube.com/reashun14
I PLAY COMBAT ARMS ONLINE!
Image


Fri Apr 16, 2010 8:36 pm
WWW
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
ok same here i would have given you the link to as: main but i lost the link

_________________
get free wii points here!


Fri Apr 16, 2010 9:18 pm
Display posts from previous:  Sort by  
 [ 8 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.