HOME | DD

S-S-X — Platformer Tutorial

Published: 2008-02-24 03:53:01 +0000 UTC; Views: 35811; Favourites: 241; Downloads: 1954
Redirect to original
Description Me and my bud FeindishDemon designed a neat little platform game tutorial.
Related content
Comments: 290

leenos In reply to ??? [2011-04-11 02:00:25 +0000 UTC]

I like the tutorial, a lot, but I can't seem too get my player to stop falling through the ground when I test it. Any fix for that?

👍: 0 ⏩: 2

hamza62240 In reply to leenos [2012-11-04 09:13:49 +0000 UTC]

Actually, when you make the ground a movie-clip, make sure, first select the ground to make a blue box around it, or some 8 squares with a circle in the middle. make it a movie clip (F8), Then, Open the properties tab, if you cannot find, go to Window > Properties. Now near where it says "Swap..." and "Movie Clip", There will be some textbox named "". Click the text box, type "ground" with no quotes in it (No special characters). now press Enter, close the panel. Now try. if it sinks through, when you convert the player a movie clip, make sure the 9 squares have the black on on the bottom, if not, just click the second one in the last row. done.

👍: 0 ⏩: 1

leenos In reply to hamza62240 [2012-11-08 14:59:14 +0000 UTC]

Oh, thanks man, that fixed it!

👍: 0 ⏩: 2

hamza62240 In reply to leenos [2012-11-22 11:25:29 +0000 UTC]

Oh and i am 7 years old

👍: 0 ⏩: 1

leenos In reply to hamza62240 [2012-11-29 14:41:50 +0000 UTC]

..uhh.. congrats?

👍: 0 ⏩: 2

hamza62240 In reply to leenos [2012-11-30 12:14:03 +0000 UTC]



What's so neutral?

👍: 0 ⏩: 1

leenos In reply to hamza62240 [2012-12-01 15:32:52 +0000 UTC]

Do you have schizophrenia? That last comment sounded like you were asking yourself.

And personally I just don't know what to say to the seven year old who replies on a two year old comment. I gave up on this low quality tutorial after an hour of messing with it, and then went and found a nice template instead. Now I don't even use Flash, or Action-script, I hard code things with PHP, MySQL, JavaScript and Ajax or Java and Lua.

(Lastly, I don't believe your age should have anything to do with how you measure your success, the way you wouldn't compare people for their gender, race, beliefs or ethnicity either.)

👍: 0 ⏩: 1

hamza62240 In reply to leenos [2012-12-01 17:59:57 +0000 UTC]

I also am good with JS and javascript, not only flash

And are you hating?

👍: 0 ⏩: 0

hamza62240 In reply to leenos [2012-11-30 12:13:44 +0000 UTC]

Umm, What's so neutral in that?

Isn't it good i am 7 i still know AS2 =O

👍: 0 ⏩: 0

hamza62240 In reply to leenos [2012-11-11 08:16:49 +0000 UTC]

Oh welcome! Hope you like it.

👍: 0 ⏩: 0

Imagunique In reply to leenos [2011-04-23 05:53:06 +0000 UTC]

yes there is. but I need to explain some things first.

A. I hope you're using Adobe flash running actionscript 2.0 becausehat's what this code calls for.

B. select the geometry you plan to use as you "ground"

c. right click it and scroll down till you see "convert to Symbol" and click that, make it a movie clip with the drop down, and name it whatever the heck you'd like.

D. click the geometry again,(a lightblue bounding box should envelope it) then click the properties tab (if you can't find it go to window>properties)

E. when the properties panel comes up there should be a spot that looks like a place you can write down the name of the file and will have the words inside. this is not a box for naming the the object, you've already done that instead type in that box ( ground ) make sure it's all lowercase and that thier are no symbols or spaces, just letters. and after that it should work properly.

You may be wonder just what and instance "is" essential it is what that shape is called at that "instant" or "frame" so that the code can tell what your talking about. If an object is instanced as char, then whenever you want to do something to the object char, or want to refer to the object char, you just have to type in char. Well actually _root.char, but that's just tecnicallity. the _root. means something but it requires even more annoying explanation. so yeah. Hope this helped, sorry it's so long.

👍: 0 ⏩: 0

Chloe45000 In reply to ??? [2011-03-06 19:06:01 +0000 UTC]

[FRENCH] Je n'ai rien compris...

I do not understand because I am French and I am 12 years old !
Could someone explain in legacy is there you please ?

👍: 0 ⏩: 3

hamza62240 In reply to Chloe45000 [2012-11-04 10:08:26 +0000 UTC]

Player code:
onClipEvent (load) {
var grav:Number = 0;
// gravity
var speed:Number = 10;
// how fast you walk
var jumpHeight:Number = 15;
// how high you jump
var slow:Number = .7;
// sets water falling speed
var slowspd:Number = speed/1.5;
// sets water walking speed
var setspeed:Number = speed;
var scale:Number = _xscale;
var ex:Number = 5;
// makes hitTests better, change for a closer hitTest (warning, more buggy if smalle, less real if further)
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (_root.water.hitTest(_x, _y, true)) {
if (grav>0) {
grav *= slow;
}
speed = slowspd;
} else {
speed = setspeed;
}
if (Key.isDown(68)) {
_x += speed;
_xscale = scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else if (Key.isDown(65)) {
_x -= speed;
_xscale = -scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {
this.gotoAndStop(3);
}
}
if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(73)) {
this.gotoAndStop(5);
}
if (Key.isDown(73) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(79)) {
this.gotoAndStop(4);
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
this.gotoAndStop(2);
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
}

Vcam code:

parentColor.setTransform(camColor.getTransform());
function camControl() {
parentColor.setTransform(camColor.getTransform());
var scaleX = sX/this._width;
var scaleY = sY/this._height;
_parent._x = cX-(this._x*scaleX);
_parent._y = cY-(this._y*scaleY);
_parent._xscale = 100*scaleX;
_parent._yscale = 100*scaleY;
}
function resetStage() {
var resetTrans = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
parentColor.setTransform(resetTrans);
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
}
// make frame invisible
this._visible = false;
// Capture stage parameters
var oldMode = Stage.scaleMode;
Stage.scaleMode = "exactFit";
var cX = Stage.width/2;
var cY = Stage.height/2;
var sX = Stage.width;
var sY = Stage.height;
Stage.scaleMode = oldMode;
// create color instances for color
// transforms (if any).
var camColor = new Color(this);
var parentColor = new Color(_parent);
// Make the stage move so that the
// v-cam is centered on the
// viewport every frame
this.onEnterFrame = camControl;
// Make an explicit call to the camControl
// function to make sure it also runs on the
// first frame.
camControl();
// If the v-cam is ever removed (unloaded)
// the stage, return the stage to the default
// settings.
this.onUnload = resetStage;


Done.

👍: 0 ⏩: 0

hamza62240 In reply to Chloe45000 [2012-11-04 09:55:14 +0000 UTC]

Ouais, désolé si vous ne comprenez pas. ce tutoriel en français m'a fallu une heure.

👍: 0 ⏩: 0

hamza62240 In reply to Chloe45000 [2012-11-04 09:54:42 +0000 UTC]

Vous pouvez le traduire.

Tout d'abord: Faire un nouveau clip avec "F8" pour ouvrir une boîte. assurez-vous que la boîte a le bouton radio "Movie Clip" sélectionné, et dans les 8 cases, assurez-vous que le noir est dans le fond. sinon, cliquez sur le second dans la dernière rangée. et quand vous avez terminé, ouvrez le panneau de propriétés lors de la sélection du joueur (Fenêtre> Propriétés) et à proximité du plan-séquence où il est dit de swap et film, il y aura une zone de texte nommée "". écrire «joueur» dans celui-ci. maintenant, double-cliquez sur le lecteur et faire 3 cadres par "F6" - Première image: Marche, deuxième et troisième saut: permanent. Maintenant, faire un clip avec le sol en lui. Faire le même processus qu'à l'étape 2, les 8 carrés et F8 blah blah. Et quand vous avez terminé, faire les mêmes: ouvrez les propriétés, puis écrire terre dans la boîte qui dit . Maintenant, sélectionnez le lecteur. maintenant appliquer les mesures indiquées dans le tutoriel pour le joueur. pour sélectionner tout, Clic droit> Code Sélectionner tout> Clic droit nouveau> Copier. Maintenant, retournez à flash 8 et ouvrez le panneau Actions (Fenêtre> Actions), puis, appliquer les actions en appuyant sur "Ctrl + V". Alors maintenant, lorsque vous le testez, ça pourrait marcher. En passant, vous pouvez ajouter des pistes dans le sol pour l'outil pinceau n'a pas d'importance! Maintenant, nous allons mettre de l'eau. juste faire toute l'eau de votre niveau, les convertir dans un clip unique, comme avec le sol, maintenant écrire «eau» dans la case qui dit nom de l'instance. Maintenant, si vous voulez l'écran pour suivre le personnage, Faire un carré. elle doit être de la même taille que la scène. vous devriez donner ce son propre layer. faire la VCAM un clip, pénétrer à l'intérieur du clip, créez un nouveau calque appelé "Actions". maintenant ajouter le code de la v-cam dans le tutoriel dans le cadre .... maintenant sortir de la VCAM. maintenant ajouter ce code au clip VCAM: onClipEvent (enterFrame) {
_y + = (_root.player._y-_y) / 4;
_x + = (_root.player._x-_x) / 4;
}

Maintenant, ne vous inquiétez pas au sujet d'un nom d'instance. Je sais que c'est ennuyeux. maintenant, vous avez terminé. Maintenant, nous allons ajouter des pièces. Faire des graphiques pièces, appuyez sur F8 et faire le même processus que le VCAM, sol et joueur. il suffit de cliquer sur OK. maintenant, ajoutez ce code à la médaille:

onClipEvent (load) {
this.swapDepths (_root.getNextHighestDepth ());
}
onClipEvent (enterFrame) {
if (_root.player.hitTest (this)) {
_root.score + +;
this.removeMovieClip ();
}
}

Maintenant ici. Ajoutons la boîte score. première fois, sélectionnez l'outil Texte. dans les propriétés, sélectionnez rien. il est dit outil Texte. près du lieu où il est dit «Text Tool", vous verrez une liste déroulante. Cliquez dessus et sélectionnez "Texte dynamique". Maintenant, trouver une autre zone de texte disant "Var:". type "score" en elle, aucune majuscule et les guillemets. Maintenant, ajoutez le début du film (même si vous avez un menu principal, toujours sur le départ), ajoutez le code "score = 0;" sans guillemets. sinon, il va dire: "NaN" si vous collectionnez les pièces de monnaie. vous l'avez fait. Maintenant vous pouvez faire votre propre niveau de conception! Amusez-vous! Français!

👍: 0 ⏩: 0

Old-Phase In reply to ??? [2011-02-08 10:51:14 +0000 UTC]

What's the highest possible score? I can't get any higher than 16.

👍: 0 ⏩: 0

blazerconz In reply to ??? [2010-12-27 04:10:59 +0000 UTC]

help! it keeps showing errors

👍: 0 ⏩: 0

MDCarter7 In reply to ??? [2010-11-18 02:45:34 +0000 UTC]

YEAH!!!! I found the glitch.

👍: 0 ⏩: 1

Imagunique In reply to MDCarter7 [2011-04-23 05:56:22 +0000 UTC]

did you know to fix the glitch you just have to reduce the variable speed a little bit so that the character can't run faster than the wall pushes him away, that or increase the wall push, but that takes more time.

👍: 0 ⏩: 0

MDCarter7 In reply to ??? [2010-11-18 00:38:00 +0000 UTC]

I lost....
great tuorial.

👍: 0 ⏩: 0

Konflagration In reply to ??? [2010-11-08 23:29:19 +0000 UTC]

Is this AS3 Code?

👍: 0 ⏩: 2

hamza62240 In reply to Konflagration [2012-11-04 09:15:36 +0000 UTC]

No. use AS2.

👍: 0 ⏩: 0

Imagunique In reply to Konflagration [2011-04-23 05:57:15 +0000 UTC]

yes and no, you can run this in AS3 but you'll have to fix a couple of things, it seems to be made for AS2.

👍: 0 ⏩: 0

BenCaraway In reply to ??? [2010-10-30 05:27:32 +0000 UTC]

Thank you so much.

👍: 0 ⏩: 0

Ninjapanda13 In reply to ??? [2010-09-19 19:15:11 +0000 UTC]

I am hesitant to keep coming back to this tutorial, simply because I hate being forced to listen to the sound loop every time T^T

But I love the tutorial! OH GOD.

👍: 0 ⏩: 0

Indemnite In reply to ??? [2010-09-10 13:57:57 +0000 UTC]

Mute button.
Seriously, that shit is annoying.

👍: 0 ⏩: 1

hamza62240 In reply to Indemnite [2012-11-04 09:57:22 +0000 UTC]

You are annoying. best music ever!!!!!!!!

👍: 0 ⏩: 0

Indemnite In reply to ??? [2010-08-05 11:30:38 +0000 UTC]

Also, the engine can be exploited to get a superjump.

👍: 0 ⏩: 0

Indemnite In reply to ??? [2010-08-05 11:27:45 +0000 UTC]

Sound toggle for the love of god.

👍: 0 ⏩: 0

Me-lin-da In reply to ??? [2010-06-19 22:05:07 +0000 UTC]

phew, it took me like, 3o mins to fix my turtle player so that he can walk right. so tired now.

👍: 0 ⏩: 0

bettyb1270 In reply to ??? [2010-06-09 23:16:37 +0000 UTC]


you are a gaming god!!!
we are not worthy

👍: 0 ⏩: 0

Kawaiinekinu In reply to ??? [2010-05-14 07:33:11 +0000 UTC]

best.
tutorial.
EVER. O_O for serious.

👍: 0 ⏩: 0

mojoismehkitty In reply to ??? [2010-05-11 02:09:54 +0000 UTC]

waaaa i cant get all of the coins!

👍: 0 ⏩: 0

CreatorKris In reply to ??? [2010-05-01 16:50:43 +0000 UTC]

Could you detail more how to make the score work.
I tried everything you describe but the score can't count.. :s

The Compiler errors say that "Statement must appear within on/onClipEvent handler"

Btw im a totally noob at this...

👍: 0 ⏩: 1

hamza62240 In reply to CreatorKris [2012-11-04 10:00:06 +0000 UTC]

NO, THE DYNAMIC TEXT CODE, NOT ON THE COIN!!!!!!

on the first frame, add score = 0;.

And on the coin, add:

onClipEvent (load) {
this.swapDepths (_root.getNextHighestDepth ());
}
onClipEvent (enterFrame) {
if (_root.player.hitTest (this)) {
_root.score + +;
this.removeMovieClip ();
}
}

the reason it says it must appear with a onClipEvent handler is cause you did NOT add it. you need to add "onClipEvent(load){" to load the frame, "onClipEvent(enterFrame){" to enter the frame.

👍: 0 ⏩: 0

Petit-Hibou In reply to ??? [2010-04-17 03:02:50 +0000 UTC]

what program do you use and is it free?

👍: 0 ⏩: 2

hamza62240 In reply to Petit-Hibou [2012-11-04 10:00:36 +0000 UTC]

Macromedia Flash 8. It is not free legally.

👍: 0 ⏩: 0

BaarsDesign In reply to Petit-Hibou [2010-05-03 22:18:56 +0000 UTC]

i Guess Adobe Flash, cuz that's the standard and no... it's not free (legally)

👍: 0 ⏩: 1

Petit-Hibou In reply to BaarsDesign [2010-05-04 20:49:45 +0000 UTC]

dang lol

👍: 0 ⏩: 0

shadow-greyblade [2010-04-09 01:43:42 +0000 UTC]

i can has .fla file please? O:

👍: 0 ⏩: 0

Higuything21 In reply to ??? [2010-02-19 19:25:30 +0000 UTC]

This is awesome, amazing presentation as others say and its a great engine too!

P.s. you next tutorial should be a mute button lol

👍: 0 ⏩: 0

cinnamonsid In reply to ??? [2010-01-12 05:13:57 +0000 UTC]

mute button please

👍: 0 ⏩: 0

BarnabasFlow In reply to ??? [2010-01-11 21:27:22 +0000 UTC]

Okay, by graphics, like ANOTHER movie clip that loops of the character walking?

I never got that clear and I always screw up my game.

👍: 0 ⏩: 0

AlfredoAVA In reply to ??? [2010-01-07 19:06:32 +0000 UTC]

Incredible tutorial, everything worked fine for me (I use AS2). This was a great help, and you two are amazing coders.

My only complaint is that I wish some of the statements/handlers in the coding was explained a little more. I've noticed that you have documented some of it, but perhaps some readers would like to know what some of the handlers actually do. Other than that, very nice. I've learned a lot.

👍: 0 ⏩: 0

Seserous In reply to ??? [2009-12-12 05:44:32 +0000 UTC]

I don't suppose you have an update for CS4? the onClipEvent (load) doesn't work because it says it is no longer supported...

👍: 0 ⏩: 1

hamza62240 In reply to Seserous [2012-11-04 10:01:34 +0000 UTC]

When you create a new document, make sure you have selected AS2 instead of AS3. i don't know if it does not work.

👍: 0 ⏩: 0

MiniatureOwly In reply to ??? [2009-12-09 04:12:11 +0000 UTC]

awesome tutorial. it works real well, except i cannot get the v-cam to work. i'll keep trying, thanks for the help

👍: 0 ⏩: 0

Msyt In reply to ??? [2009-11-18 13:18:47 +0000 UTC]

awesome

👍: 0 ⏩: 0

jrobbins In reply to ??? [2009-11-14 22:22:50 +0000 UTC]

Where exactly do I put the script for the player?

👍: 0 ⏩: 1

hamza62240 In reply to jrobbins [2012-11-04 10:02:54 +0000 UTC]

Select the player, open the actions panel (F9), Go back to browser, right click code, select all, right click again, copy, back to flash, in actions panel, paste Ctrl + V.

DONE!!!!!!!1111111111111 ^_^

👍: 0 ⏩: 0


<= Prev | | Next =>