Hey guys, how’s everyone doing?Well I’m pretty new to Actionscript, I consider myself a n00bie, which is why I come to you guys. I was just fooling around with a little “gravity” here, making a ball move in different directions and switching directions when it touches a wall. Everything’s going fine. Now the thing is I want to be able to control the gravity variable by an input text, but so far I’ve gotten no results. This is my code so far :
var ygravity = 0;var xgravity = 0;var yspeed = 0;var xspeed = 0;var yphase = 0;var xphase = 0;var limit = 500;_root.ball_mc.onEnterFrame = function() { if (yspeed>=limit) { yspeed = limit-1; } if (xspeed>=limit) { xspeed = limit-1; } if (yphase == 0) { yspeed += ygravity; this._y += yspeed/50; } if (yphase == 1) { yspeed += ygravity; this._y -= yspeed/50; } if (xphase == 0) { xspeed += xgravity; this._x += xspeed/50; } if (xphase == 1) { xspeed += xgravity; this._x -= xspeed/50; } if (this.hitTest(_root.rightb_mc)) { xphase = 1; } if (this.hitTest(_root.leftb_mc)) { xphase = 0; } if (this.hitTest(_root.topb_mc)) { yphase = 0; } if (this.hitTest(_root.bottomb_mc)) { yphase = 1; }};
My problem is that whenever I try to change the gravity via the input text, it’ll jump directly to the limit variable, which would give it a speed of 500. I want it to be able to accelerate, given the number that I put in the input box, not jump straight to the limit. I’m sure you guys will have no problem with this, and I’m hoping to keep learning from this forum.Thanks in advance