luekil
05-12-2011, 11:38 AM
Hi everyone. So I am making a game in flash using actionscript 2. The idea is that there are several lines of moving objects and if you press space you release an object and it has to fall on the moving object below that one and the objects have to stack. I haven't used a lot of actionscript so don't really know how to do this, was using this code:
onClipEvent(enterFrame) {
speed = 5;
this._x +=speed;
{
//This should be for the object to fall straight through Y
if (Key.isDown(Key.SPACE)){
this._x -= speed;
this._y += 10;
}
//This should be for the falling object to move with the moving object below it
if(_root.torso.hitTest(this)){
this._x -= 7;
this._y -= 10;
}}}
But obviously it doesn't work. First I would like that I don't have to leave Space pressed for the falling of the object to continue (have to leave it pressed or the object continues moving through X). Also When it hits the "torso" it will pretty much go around it and won't really follow it so wanted to know how to do this as well.
So basically I would like to know how to use space for the object to keep falling and not keep it pressed and how to make an object stack on the other and follow it.
Thanks everyone for your time and would be really thankful if you can help me.
P.S: Sorry for so much text
onClipEvent(enterFrame) {
speed = 5;
this._x +=speed;
{
//This should be for the object to fall straight through Y
if (Key.isDown(Key.SPACE)){
this._x -= speed;
this._y += 10;
}
//This should be for the falling object to move with the moving object below it
if(_root.torso.hitTest(this)){
this._x -= 7;
this._y -= 10;
}}}
But obviously it doesn't work. First I would like that I don't have to leave Space pressed for the falling of the object to continue (have to leave it pressed or the object continues moving through X). Also When it hits the "torso" it will pretty much go around it and won't really follow it so wanted to know how to do this as well.
So basically I would like to know how to use space for the object to keep falling and not keep it pressed and how to make an object stack on the other and follow it.
Thanks everyone for your time and would be really thankful if you can help me.
P.S: Sorry for so much text