First time here? First time here? Newsletter Signup Newsletter
651326 Members and growing! | Flash Jobs
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!

Comments

  • 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: doc_chin7
» Description:

The flash's horizontal road drive was done in CS4 and was upgraded to CS6. The car responds to right/ left key and flash will auto-generate the movement of roads from left-right or right-left based on random number. Have fun driving in this virtual environment and avoid other cars... :) If you are creative, a road driving game can be created from it.

Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.