Stick Page Forums Archive

simple platformer tutorial [Flash][Actionscript]

Started by: skazzi | Replies: 57 | Views: 14,529 | Closed

skazzi

Posts: 0
Joined: Jun 2025
Sep 15, 2005 8:47 PM #711
ok first make you player and make him a movie clip name the movie clip "player"
then make sure this dot is in the middle
Image
now add this to your player
onClipEvent (load) {
y = jump=0;
speed = 5;
}
onClipEvent (enterFrame) {
xmax = this.getBounds(_root).xMax;
xmin = this.getBounds(_root).xMin;
ymax = this.getBounds(_root).yMax;
if (Key.isDown(Key.RIGHT) && !_root.ground.hitTest(xmax+speed, _y, true)) {
_x += speed;
}
if (Key.isDown(Key.LEFT) && !_root.ground.hitTest(xmin-speed, _y, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x, ymax-(y/2), true)) {
jump = true;
y = 0;
} else {
y -= 2;
jump = false;
}
if (jump && Key.isDown(Key.SPACE)) {
y = 13;
}
_y -= y;
}

next to make your platforms make sure there ONLY BOXES!!!!!!!!!!!! or eles this wont work.... now that you made all of the platforms highlight them make it a movieclip and name it ground then click on the ground and hit the little arrow down at the bottom pointing up click that then you should see
"instance name" click that and make it say ground also... now once you have done that it should work.... try it out

*controls are move right is right arrow move left is left arrow jump is space*

thanks and if this helped you will you please rep me
bamaboy

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:08 AM #714
hmmm nice....it is a little basic but its ok....it will start some people in a good direction...
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:10 AM #715
well its suppose 2 be basic :P thanks tho
BarneyGumball

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:16 AM #716
so is it only squares?

or does boxes include rectangles?

just makin sure...
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:22 AM #717
rectangels squares all dat crap cant be like a brush line and shit...
BarneyGumball

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:38 AM #718
I know that silly =D

I was just askin coz i'm too lazy to look at the code right now

Edit: Ummmmm dude....

with the part where you make an MC in the picture it has button selected...

Just to let you know you should fix it
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:46 AM #719
huh lol you lost meh
FrAnKeH
2

Posts: 602
Joined: Aug 2005
Rep: 91

View Profile
Sep 16, 2005 12:49 AM #720
thats actualy quite a complicated way to do it.
As far as understanding the code.
Like for the platfrom hittest:
for(i=0;i<999;i++){ 
if(_root.player.hitTest("_root.ground" + i)){
ground = eval("_root.ground" +i)
}
if(_root.player.hitTest(ground)){
//do crap
}
}



that way you can have multiple platforms.
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:52 AM #721
no no no no i already no how 2 make multiple 1s you just make the platforms and dont make each 1 a movieclip just higlight them all and make them it and do what i said
ill show you a lil game i made with it fast

http://i17.photobucket.com/albums/b74/skazzi/test1.swf
FrAnKeH
2

Posts: 602
Joined: Aug 2005
Rep: 91

View Profile
Sep 16, 2005 12:57 AM #722
Ah yes i get you.
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 12:58 AM #723
:D yah lol its a pretty cool game :( hard tho
Red_Dude

Posts: 0
Joined: Jun 2025
Sep 16, 2005 1:20 AM #724
Quote from skazzi
huh lol you lost meh


he means that in your picture with the arrow pointing you have "button" selected instead of "movie clip"
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 1:24 AM #725
ooooooooooo i was doin it fast sorry
BarneyGumball

Posts: 0
Joined: Jun 2025
Sep 16, 2005 3:19 AM #733
it was kinda stupid lol =D
skazzi

Posts: 0
Joined: Jun 2025
Sep 16, 2005 3:28 AM #734
its suppose 2 be dumb and simple i wasnt really tryin 2 get at anythin with that
Website Version: 1.0.4
© 2025 Max Games. All rights reserved.