How to respawn objects at random side and random alternately using factory?

So when an object goes outside the top of the screen it should be spawned at the bottom again?

function update(self, dt)
	local pos = go.get_position()
	-- move up 10 pixels/second
	pos.y = pos.y + 10 * dt
	-- if position is outside top edge of screen then move it to the bottom
	if pos.y > your_screen_height_here then
		pos.y = 0
	end
	go.set_position(pos)
end
1 Like