Psirus
05-27-2008, 11:04 PM
Ok I am relatively new to actionscript.
It is only a game of pong, but basically I have collision detection and when the ball hits the object I want it to speed up.
I have the collision detection (sort of) working:
onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
trace("Hit");
} else {
trace("Miss");
}
}
When 'ball' hits 'object' flash prints "Hit" in the output window, BUT, it does not print "Miss" when it is not hitting the object.
Anyway thats not what I am asking.
The 'ball' contains the variable:
this.fullspeed=25;
All I want to do is double it to 50, so if I change the collision to the following it should work:
onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
ball.fullspeed=50;
} else {
trace("Miss");
}
}
But alas it does not seem to work. I can't figure out how to control the variables in one object from another, as the variables do not seem to be global, if that makes sense.
Thanks for your help,
Dan
It is only a game of pong, but basically I have collision detection and when the ball hits the object I want it to speed up.
I have the collision detection (sort of) working:
onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
trace("Hit");
} else {
trace("Miss");
}
}
When 'ball' hits 'object' flash prints "Hit" in the output window, BUT, it does not print "Miss" when it is not hitting the object.
Anyway thats not what I am asking.
The 'ball' contains the variable:
this.fullspeed=25;
All I want to do is double it to 50, so if I change the collision to the following it should work:
onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.object)) {
ball.fullspeed=50;
} else {
trace("Miss");
}
}
But alas it does not seem to work. I can't figure out how to control the variables in one object from another, as the variables do not seem to be global, if that makes sense.
Thanks for your help,
Dan