PDA

View Full Version : gravity problem


gamemakea
03-11-2008, 02:11 AM
I have it so when i hit space bombs fall, but the gravity i put for bombs2 is being used for the plane(which is what this code is in).
So basically the bombs appear to stay on plane, and than the plane falls, becuase normally the plane doesn't have gravity.


onClipEvent(enterFrame){
if (Key.isDown(Key.SPACE)) {
attachMovie("bombs2", "bombs2", 1, {_x:start_ball_x, _y:start_ball_y});
bombs2.onEnterFrame = function() {
gravity = 0.1;
yspeed += gravity;
_y += yspeed;
}
}

sunlis
03-11-2008, 04:10 AM
Paths, my dear Watson. Paths.
onClipEvent(enterFrame){
if (Key.isDown(Key.SPACE)) {
attachMovie("bombs2", "bombs2", 1, {_x:start_ball_x, _y:start_ball_y});
bombs2.onEnterFrame = function() {
gravity = 0.1;
yspeed += gravity;
this._y += yspeed;
}
}
};

Without the "this.", you were telling the plane to go down, not the bomb within it. ;)

CyanBlue
03-11-2008, 01:29 PM
Moving to the Gaming and Game Development forum...