|
-
Okay guys,
I've got a ball mc in the centre of the screen with the ground mc moving around and a car mc inside the ground mc.
When ball mc hits car mc it bounces off.
The only problem is I can only have one car. I can't copy and paste a bunch of cars in the ground mc to bounce off because only the original one works.
I based the coding idea on Mad sci's platform engine where you can copy and paste platforms. But mine doesn't work.
Here's the code:
IN THE GROUND MC
onClipEvent (load) {
mover = 5;
whack = "off";
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this._x += mover;
}
if (Key.isDown(Key.RIGHT)) {
this._x -= mover;
}
if (Key.isDown(Key.UP)) {
this._y += mover;
}
if (Key.isDown(Key.DOWN)) {
this._y -= mover;
}
if (whack eq "on") {
mover = -10;
}
if (whack eq "off") {
mover = 5;
}
}
IN THE CAR MC INSIDE GROUND MC (it hasn't been given any instance name)
onClipEvent (enterFrame) {
if (hitTest(_root.ball)) {
_root.ground.whack = "on"
} else {
_root.ground.whack = "off"
}
}
THE BALL IS EMPTY (Apart from instance name)
Any ideas guys?
Cheers.
-
Senior Member
I hope this works.
In second car use
onClipEvent (enterFrame) {
if (hitTest(_root.ball)) {
_root.ground.whack2 = "on"
} else {
_root.ground.whack2 = "off"
}
}
And in ground mc:
if (whack eq "on" or whack2 eq "on") {
mover = -10;
}
if (whack eq "off" and whack2 eq "off") {
mover = 5;
}
More cars? Just keep adding them same way.
Only problem will be, I think, all your cars will bounce, if 1 of them hits the ball. Still, you could try it
-
Thanks for your help mate, but unfortunately it activates the second car and ignores the first one!
Bloody code!
I've just been looking at the GTA code.
I think I can get something from that.
Cheers anyway.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|