Controlo por Teclado Vejam pf

Godlike_Killer

Power Member
Após pesquisa concluí (talvez incorrectamente) que um Movimento por teclado com as teclas WASD em Flash se faria do seguinte modo:

Código:
[FONT=monospace][LIST=1]
[*]onClipEvent (enterFrame) {
[*]        if (Key.isDown(Key.getAscii(65)) && Key.isDown(Key.getAscii(87))) {
[*]                this._rotation -= 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(68)) && Key.isDown(Key.getAscii(87))) {
[*]                this._rotation += 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(65)) && _root.z > 0.1&& (!Key.isDown(Key.getAscii(87)) ) && (!Key.isDown(Key.getAscii(83)) )) {
[*]                this._rotation -= 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(68))  && _root.z > 0.1&& (!Key.isDown(Key.getAscii(87)) ) && (!Key.isDown(Key.getAscii(83)) )) {
[*]                this._rotation += 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(65)) && Key.isDown(Key.getAscii(83))) {
[*]                this._rotation += 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(68)) && Key.isDown(Key.getAscii(83))) {
[*]                this._rotation -= 2.6;
[*]        }
[*]        if (Key.isDown(Key.getAscii(87))) {
[*]                this._y -= (Math.cos(Math.PI/180 * this._rotation))*_root.z;
[*]                this._x += (Math.sin(Math.PI/180 * this._rotation))*_root.z;
[*]        }
[*]        if (Key.isDown(Key.getAscii(83)) ) {
[*]                this._y -= Math.cos(Math.PI/180 * this._rotation) *_root.z;
[*]                this._x += Math.sin(Math.PI/180 * this._rotation)*_root.z;
[*]        }
[*]        if (Key.isDown(Key.getAscii(87))&& !(Key.isDown(Key.getAscii(83)) ) && _root.z > -2&& _root.z < 3) {
[*]                _root.z += 0.08;
[*]        }
[*]        if (Key.isDown(Key.getAscii(83)) && !(Key.isDown(Key.getAscii(87)) ) && _root.z > -2&& _root.z < 3) {
[*]                _root.z -= 0.08;
[*]        }
[*]        if ((_root.z > 0.1) && (!Key.isDown(Key.getAscii(87)) )&& (!Key.isDown(Key.getAscii(83)) )) {
[*]                this._y -= (Math.cos(Math.PI/180 * this._rotation))*_root.z;
[*]                this._x += (Math.sin(Math.PI/180 * this._rotation))*_root.z;
[*]                _root.z -= 0.04;
[*]        }
[*]        if ((_root.z < -0.1) && (!Key.isDown(Key.getAscii(87)) )&& (!Key.isDown(Key.getAscii(83)) )) {
[*]                this._y -= (Math.cos(Math.PI/180 * this._rotation))*_root.z;
[*]                this._x += (Math.sin(Math.PI/180 * this._rotation))*_root.z;
[*]                _root.z += 0.04;
[*]        }
[*]        if ((_root.z < 0.1) && (!Key.isDown(Key.getAscii(87)) ) && (!Key.isDown(Key.getAscii(83)) ) && _root.z >= 0 ) {
[*]                _root.z = 0;
[*]        }
[*]        if ((_root.z > -0.1) && (!Key.isDown(Key.getAscii(87)) ) && (!Key.isDown(Key.getAscii(83)) )&& _root.z <= 0 ) {
[*]                _root.z = 0;
[*]        }
[*]        if (Key.isDown(Key.getAscii(87))&& (Key.isDown(Key.getAscii(83)) )) {
[*]                _root.z /= 1.1;
[*]        }
[*]}[/LIST][/FONT]


Estou a fazer bem ou não é assim que se procede? Eu estava convencido que era assim, mas como este código não produz movimento, vim procurar aqui ajuda, se me pudessem orientar era óptimo.
Muito obrigado.
 
Back
Topo