First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: mark
Right, To build a game, you have to start out by giving two layers, one called character, or man, or the name of the man you are controlling and another layer called layout or background. You can add a 'Actions' layer if you want. Now, on the first keyframe, of any layer add a button, and maybe a nice instruction text on how to play your game. now, on the next keyframe on the background layer, draw a background. Then on the character/man layer draw a spot, convert it to a symble, have the behavior 'movie clip' now, back to your movie, add a stop action to that frame, with the background, So that the movie doesn't play whilst you are moving your character. Now, add the instance name 'man' to your man/character in the properties panel. Then, add this action to him. onClipEvent (load) { moveSpeed = 3; } onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed; } else if (Key.isDown(Key.UP)) { this._y -= moveSpeed; } else if (Key.isDown(Key.DOWN)) { this._y += moveSpeed; } else if (Key.isDown(Key.LEFT)) { this._x -= moveSpeed; } } Basically, this means : When the clip loads 'movespeed' is of 3 pixels. When you enter the frame, if the RIGHT key is down it adds 'movespeed' (3 pixels) X to the man, which makes him move to the right ! If you don't know, X is a left vertical line, adding something to it makes it move to the right. Y is a horizontal top line, by adding something to it it moves down and vice versa. Note : movespeed is an imaginary name, you can change it if you change it in all the script, and you can modify 3 to make faster and slower movements. So, the character can move now, but, have you noticed ? HE GOES STRAIGHT THROUGH WALLS ! Now, you know what X and Y are, you can understand the script i will tell you in the minute. Now, convert each limit/border/wall to a symbol, one symbol per wall, give them these instance names, such as wallup, wallright1, walldown3 or wallleft4, The numbers are because their could be a wad of walls. Now, for the code you will add TO THE CHARACTER : onClipEvent (enterFrame) { if (this.hitTest(_this.wallleft)) { _x = _x+10; } } THIS CODE IS FOR A LEFT BORDER This code shows that, if you the HitTest is true, it means you have it something, it will add 10 to X, which will make you bounce off. _____________________________ onClipEvent (enterFrame) { if (this.hitTest(this.wallup)) { _y = _y+10; } } THIS CODE IS FOR A TOP BORDER ________________________________ onClipEvent (enterFrame) { if (this.hitTest(this.walldown)) { _y = _y-10; } } THIS IS FOR A BOTTOM BORDER ____________________________ onClipEvent (enterFrame) { if (this.hitTest(this._parent.outsidelimit3)) { _x = _x-10; } } THIS IS FOR A LEFT BORDER _____________________________ Now, you have the code for all the borders, how is your man going to go inside a house or something like that. First, add a Instance name to your first playing frame, so you can recognize it later. To add a staircase or something to go somewhere else, create a movieclip, which can be a door or stairs, you choose and add this actionscript to IT (not the man) : onClipEvent (enterFrame) { if (this.hitTest(this._parent.man)) { _root.gotoAndStop("inside"); } } This basically means : As you enter the frame, if the stairs (this) hits the man (this._parent.man) it goes to and plays a frame called inside. *NOTE* : Without the " " it has to be a number, which, i think is 3 (1 : the menu, 2 : the first playing frame and 3 : the second playing frame) Now you know the basics of an RPG, wait for my next tutorial that covers how to make a money based game, where you can work, buy and rob !
» Level Basic

Added: 2005-01-02
Rating: 3 Votes: 36
(10 being the highest)
» Author
Hi, i am an 11 y/o kid that is mad about flash animating.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.