Im been stuck for a while trying to get this to work. Basically I have this object which floats about randomly and moves through the screen. when the player touches it, I want that floating object to revert back to its starting position or another random location so that it can float in again.
Any ideas how i’d go about doing this? is there a better way to do this? is there a code I need to put into the collision which makes the object basically spawn again?
Right now all the happens is when it floats of screen it goes back to beginning again.
function moveUFO(self,event) if self.x \< -50 then self.x = math.random(500,1500) self.y = math.random(90,220) self.speed = math.random(2,6) self.amp = math.random(20,100) self.angle = math.random(1,360) else self.x = self.x - self.speed self.angle = self.angle + .1 self.y = self.amp\*math.sin(self.angle)+self.initY end end
