View Full Version : [AS1] help me making a game
sydazak
08-20-2005, 01:24 AM
hi i made a game called masze i made all the walls and a ball i named the ball (car) and i made some squigly lines when i click play putton when i move the ball i goes threw the walls i want the ball (car) to not go threw the boundries i want an code for boundries
mexican
09-11-2005, 11:40 PM
Hi,
I can't say to much without some of your code to guid me but what I can say is that the hitTest function can help you out. Basically you have a moving object that must stop once it hits another object. That means that the piece of code that is moving your car must change the moment that your hitest function is activated. This code was placed inside the car object
onClipEvent(load)
{
var movement:Number = 10;
}
onClipEvent(enterFrame)
{
//code that moves the object
this._x +=movement;
//on hitest prevent the object from moving further
if (this.hitTest(this._parent.wall))
{
movement =0;
}
}
Here the hitest function is measure if the current object (the car) has hit the wall object. If is has stop its movement by making movement =0
magicwand
09-15-2005, 10:00 PM
onClipEvent(load)
{
var movement:Number = 10;
}
onClipEvent(enterFrame)
{
//code that moves the object
this._x +=movement;
//instead of hittest use below. hittest is ok but this is better.
if (this._x > 300)
{
movement =0;
}
}
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.