Quando quero mover o barco e atirar ao mesmo tempo, ou você move o barco ou atira, não é possível fazer os dois ao mesmo tempo. Em AS 2.0 funciona corretamente.
Em AS 2.0 seria:
barco.onEnterFrame = function () {
if(Key.isDown(Key.UP)) {
this._y-=velocidade;
}
if(Key.isDown(Key.DOWN)) {
this._y+=velocidade;
}
if(Key.isDown(Key.LEFT)) {
this._x-=velocidade;
}
if(Key.isDown(Key.RIGHT)) {
this._x+=velocidade;
}
if(Key.isDown(Key.SPACE)) {
this.atirar();
}
}
Em AS 3.0
public function Barco() {
stage.addEventListener(KeyboardEvent.KEY_DOWN, tecla);
}
private function tecla(event:KeyboardEvent){
if (event.keyCode == 37 && fase.colidido == false){ //LEFT
this.x -= velocidade;
}
if (event.keyCode == 39 && fase.colidido == false){ //RIGHT
this.x += velocidade;
}
if (event.keyCode == 32 && fase.colidido == false){ // SPACE
fase.atirou = true;
}
}
Se alguém estiver trabalhando com AS 3.0 e souber como ajudar, eu agradeço!

Help














