Why the code doesn’t work. I need to make sure there is a random background when initializing an object.
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("@render:", "use_fixed_fit_projection")
--math.randomseed(socket.gettime())
self.bg = math.random()
if self.bg > 0.5 then
go.set("bg#sprite", "default_animation", "bg1")
else
go.set("bg#sprite", "default_animation", "bg2")
end
end
Editor scripts are completely different from game scripts, they’re for running custom actions in the editor. Those property names are generally not the same as the ones available to your game code.