Please Note: Follow all instructions carefully. Missing any of them will make the whole thing Fail!
Some basic gaming concepts
In this tutorial, we will go through some basic concepts every game will definitely have.
Objective
To understand how to
Objective
To understand how to
- make an object move to a desired position (by code)
- rotate an object clockwise and anticlockwise (by code)
- increase/decrease length of an object (by code)
- increase/decrease breath of an object (by code)
So i will be explaining how to do this.
Note: we need to edit the movieclip and make the object move to the center of the movieclip for best results. see how after the code
- Get these built in buttons from the common libraries. Goto Windows➜common libraries➜buttons. I chose bar blue . You can chose what you like
- Double click it and remove the text layer in them
- Add a new layer in the main timeline called text
- Create textboxes(static) and place them over the buttons, labelling them
- Lock the layer , so it won't disturb you
- Then get any small picture like the car above
- Import it to stage(File➜Import➜To Stage) and convert it into a symbol -movieclip (F8) and name it anything u like( i named it car)
- Give it an instance name( i gave it an instance name car) in properties.
- Finally select each button and add the code in the action window(F9)
- Run it( ctr+Enter)
Note: we need to edit the movieclip and make the object move to the center of the movieclip for best results. see how after the code
CODE
Before we begin, you must know one thing . The flash stage is like a cartesian plane( coordinate geometry) . Well there are 2 differences however origin of the plane or graph starts from the left top corner. And if the Y-axis is positive. It means the object is below the origin.
//CODE FOR POSITION // to make the object go Down //car._y+=10 means make the Y position of the object increases by 10 pixels on(release){ car._y+=10 } // to make the object go UP //car._y-=10 means that the Y position of the object decreases by 10 pixels on(release){ car._y-=10 } // to make the object go RIGHT //car._x+=10 means that the X position of the object increases by 10 pixels on(release){ car._x+=10 } // to make the object go LEFT //car._x-=10 means that the X position of the object decreases by 10 pixels on(release){ car._x-=10 } //CODE FOR SCALING // to make the object increase in height //car._yscale+=10 means that the Yscale of the object increases by 10 on(release){ car._yscale+=10 } // to make the object decrease in height //car._yscale-=10 means that the Yscale of the object decreases by 10 on(release){ car._yscale-=10 } // to make the object increase in breath //car._xscale+=10 means that the Xscale of the object increases by 10 on(release){ car._xscale+=10 } // to make the object decrease in breath //car._xscale-=10 means that the Xscale of the object decreases by 10 on(release){ car._xscale-=10 } //CODE FOR ROTATION // to make the object rotate clockwise //car._rotation+=10 means that the rotation angle of the object increases by 10 degrees on(release){ car._rotation+=10 } // to make the object rotate counter clockwise //car._rotation-=10 means that the rotation angle of the object decreases by 10 degrees on(release){ car._rotation-=10 }