I’m trying to make a simple space shooter for learning the game engine.
I want to enemy spawn diffirent position on the scene but using math with screen dimension, it doesnt work.
local enemy_spawn_rate = 60 -- per minute
function init(self)
local pos = go.get_position()
local window_x, window_y = window.get_size()
pos.x = window_x / 2
pos.y = window_y - 20
go.set_position(pos)
print(window_x)
timer.delay(enemy_spawn_rate / 60, true, function()
factory.create("#factory")
pos.x = math.random(window_x, 0)
go.set_position(pos)
end)
end
ERROR:SCRIPT: main/enemy_spawner.script:17: bad argument #2 to 'random' (interval is empty) stack traceback: [C]:-1: in function random main/enemy_spawner.script:17: in function <main/enemy_spawner.script:14>