Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here

Create Speaking Characters for your website and Flash movies. 15 Day Free Trial




PHP Scripts

 

 Home > Tutorials  > Gaming

how to make a laser maze game

Author: Rock jaw | Email


Advertisement


MAKING THE CHARACTER

-in the "lvl1" frame, on a new layer called "dude" create a circle for your dude....(other tutes have better ways to make him move....but this will suffice!)
-use F8 to make him into a movie clip and call his instance "dude"
- give him this action script...



onClipEvent (load) {
moveSpeed = 7;
}
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;
}
}




-This makes him move at a speed of 7....change the moveSpeed to make him faster or slower
-now this is where our friends the the walls come in...give "dude" these actions after the last script:



onClipEvent (enterFrame) {
if (this.hitTest(this._parent.left)) {
_x = _x+10;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.up)) {
_y = _y+10;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.down)) {
_y = _y-10;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.right)) {
_x = _x-10;
}
}



Now your character will bounce off the walls...literally (WARNING! whatever you do... dont make your charecters speed higher than 10! unless you keep the amount you bounce higher than the characters speed, he will go through the borders otherwise)

(try it out, your dude should be able to walk around and not go through the borders)


| 1 | 2 | 3 | 4 | 5 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

7 users online