Hello… I’m part way through the basics of a game and i have managed to create a bouncing ball with gravity effect, jumping and movement. i have gone with a hitTest on the ground for the programme instead of just the ._y co.ords because i wanted to put multiple platforms in (think like mario…) it all looks ok but i have an instance of “floor” and an instance of “ball” which works great but i wanted to bring in a few other instances of “floor” to work with the hitTest… i have since found out this wont work as each instance has to be unique… i have been reading a few other threads and have found out that i can still use this method by using a for loop on a variable in my code and just name every new instance in sequecial order… floor1, floor2, floor3 etc… it makes sence … ish. but i cant get the code to work… if some one has a minute can they have a look at my code and give me a few pointers… many thanks…
onClipEvent (load) {
gravity = 2 ;
speedy = 0;
bounce = -0.40 ;
// jumping variables
startspeed = 20;
jumping = 0;
}
onClipEvent (enterFrame) {
speedy += gravity ;
this._y += speedy ;
if (this.hitTest(_root.floor) == true) {
this._y = _root.floor._y;
speedy *= bounce;
if (Key.isDown(Key.SPACE)) {
jumping = 1;
starttime = getTimer()/90 ;
startpos = _y;
}
}
if ( jumping==1) {
time = getTimer()/90-starttime;
_y = _y-(startspeed-gravity*time);
if (_y>startpos) {
_y = startpos;
jumping = 0;
}
}
if (Key.isDown(Key.LEFT)) {
this._x += -5;
}
if (Key.isDown(Key.RIGHT)) {
this._x += +5;
}
}