Inicio > Flash > lendy > se podria decir : controlar un objeto?

se podria decir : controlar un objeto?

Experto:
Usuario:
Fecha: 23/05/2003
Valoración: (5,00 sobre 5) Categoría: Flash
23/05/2003
liimatainen, usuario preguntando en Flash
Usuario
hola , me gustaria saber como podria, a un cuadrado o cualquier otro objeto hacerlo mover hacia la derecha si presiono la tecla derecha y haci con las demas flechas ..no se si se entiende.. pues a lo que quiere llegar es a crear un juego ..bueno creo que me falta mucho aun jeje ....... gracias.
23/05/2003
liimatainen, experto respondiendo en Flash
Experto
hOLA:

pon este codigo en un movieclip y veras...
Es de un ejemlo muy bueno


onClipEvent (load) {
// declare and set initial variables
thrust = 1;
decay = .97;
maxSpeed = 15;
}
onClipEvent (enterFrame) {
// rotate right or left
if (Key.isDown(Key.RIGHT)) {
_rotation += 10;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
//
//
if (Key.isDown(Key.UP)) {
// calculate speed and trajectory based on rotation
xSpeed += thrust*Math.sin(_rotation*(Math.PI/180));
ySpeed += thrust*Math.cos(_rotation*(Math.PI/180));
flames._visible = 1;
} else {
// deccelerate when Up Arrow key is released
xSpeed *= decay;
ySpeed *= decay;
flames._visible = 0;
}
//
// maintain speed limit
speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed));
if (speed>maxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
//
// move beetle based on calculations above
_y -= ySpeed;
_x += xSpeed;
//
// loop to opposite side of the stage when the beetle travels off-screen
//ESTO REPONE EL MOVIE CLIP CUANDO SALE DEL STAGE
if (_y<0) {
_y = 232;
}
if (_y>232) {
_y = 0;
}
if (_x<0) {
_x = 465;
}
if (_x>465) {
_x = 0;
}

Suerte
23/05/2003
liimatainen, usuario preguntando en Flash
Usuario
muchas gracias !! veré que resulta
Más opciones
Enlaces patrocinados