Okay i am messing with action script and i have it when u press space, it reverses gravity, but when u release space, it returns to normal. So far that works, but i have it when it hits a block on the stage, it stops moving.
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)) {
gravity = -2;
}
else {
gravity = 2;
}
}
okay now if i leave out the else part the ball will fly up and not coem back down when i release space, but with the “else” bit, it sinks through the block that it hits.
Heres everything ive got, jsut make a circle, instance name “ball”, put a block under it, instance name “block”. thats my setup, all of these actions go into the ball.
onClipEvent (load) {
gravity = 2 ;
speedx = 0 ;
speedy = 0 ;
}
onClipEvent (enterFrame) {
speedy = speedy + gravity ;
this._x += speedx/1 ;
this._y += speedy/1 ;
}
onClipEvent (enterFrame) {
if (_root.ball, hitTest(_root.block)) {
speedy = 0;
speedx = 0;
gravity = 0;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)) {
gravity = -2;
}
else {
gravity = 2;
}
}
I know its messy and could really be cleaned up, but im learning. Thanks in advance for any help