¿Cómo puedo mover mis objetos en la pantalla al azar en Corona?

I want my display objects to move on the screen with a velocity and without any interactions. How can i do that with corona? Thanks.

preguntado el 04 de julio de 12 a las 09:07

1 Respuestas

First you have to add your display object to the physics, and then set its velocity to a random value. You can use a timer to periodically change the movement of the display object. For example:

physics = require("physics");
physics.start()
rectangle = display.newRect(0, 0, 50, 50)
physics.addBody(rectangle, "kinematic", {isSensor = true})
function moveRandomly()
rectangle:setLinearVelocity(math.random(-300,300), math.random(-300,300));
end
timer.performWithDelay(500, moveRandomly, -1);

Respondido 05 Jul 12, 12:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.