I’ve tried to look in other topics, but I have connected a camera to a moving sprite and the orthographic projection isn’t working, every time I build the project just black comes up. This is the code for the sprite :
function init(self)
msg.post("camera#Camera", "acquire_camera_focus")
msg.post(".", "acquire_input_focus")
msg.post("#", "menu")
self.play = 0
-- 0 = none; 1 = play; 2 = win; 3 = lose; 4 = game
self.timer = 0
self.game = 0
end
function update(self, dt)
if (self.play == 1) then
go.set_position(vmath.vector3(560, 970, 0))
local timer = self.timer
self.timer = timer + 1
if (self.timer == 600) then
msg.post("enemy#enemy", "play")
self.timer = 0
self.play = 4
msg.post("enemy#enemy", "play")
msg.post("player#player", "play")
end
end
if (self.play == 2) then
go.set_position(vmath.vector3(560, 970, 0))
local timer = self.timer
self.timer = timer + 1
if (self.timer == 600) then
self.timer = 0
go.set_position(vmath.vector3(560, 970, 0))
end
end
if (self.play == 3) then
go.set_position(vmath.vector3(560, 970, 0))
local timer = self.timer
self.timer = timer + 1
if (self.timer == 600) then
self.timer = 0
go.set_position(vmath.vector3(560, 970, 0))
end
end
if (self.play == 4) then
go.set_position(go.get_position("player"))
if (pos.x > 34) then
pos.x = 40
end
if (pos.x < 34) then
pos.x = 40
end
if (pos.y > 34) then
pos.y = 40
end
if (pos.y < 34) then
pos.y = 40
end
end
end
function on_message(self, message_id, message, sender)
if (message.id == hash("play")) then
self.play = 1
end
if (message.id == hash("dates")) then
go.set_position(vmath.vector3(560, 970, 0))
end
if (message.id == hash("win")) then
self.play = 2
end
if (message.id == hash("lose")) then
self.play = 3
end
if (message.id == hash("menu")) then
go.set_position(vmath.vector3(560, 970, 0))
end
end
A lot of the placements are just copy and paste, and will eventually change.