Todoexpertos.com
http://www.todoexpertos.com
La respuesta está en Internet
Información de la pregunta
Título:
se podria decir : controlar un objeto?
Experto:
lendy
Valoración:
5
Fecha:
23/05/2003
se podria decir : controlar un objeto?
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.
Re: se podria decir : controlar un objeto?
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
Pregunta finalizada. Valoración: 5.
muchas gracias !! veré que resulta
Volver al mensaje
http://www.todoexpertos.com/categorias/tecnologia-e-internet/desarrollo-de-sitios-web/flash/respuestas/503549/se-podria-decir-controlar-un-objeto