56 lines
1.7 KiB
Text
56 lines
1.7 KiB
Text
local cloud_speed = 50 -- pixels per second
|
|
|
|
function init(self)
|
|
msg.post(".", "acquire_input_focus")
|
|
go.set_position(vmath.vector3(1055,542,0))
|
|
-- sprite.set_constant("#cloud1", "tint", vmath.vector4(1, 1, 1, 0.9))
|
|
end
|
|
|
|
function final(self)
|
|
-- Add finalization code here
|
|
-- Learn more: https://defold.com/manuals/script/
|
|
-- Remove this function if not needed
|
|
end
|
|
|
|
function update(self, dt)
|
|
local pos = go.get_position("cloud1")
|
|
pos.x = pos.x - cloud_speed * dt
|
|
|
|
if pos.x < -467 then -- assuming cloud width is ~64px
|
|
pos.x = 1055+467;
|
|
end
|
|
go.set_position(pos)
|
|
end
|
|
|
|
function fixed_update(self, dt)
|
|
-- This function is called if 'Fixed Update Frequency' is enabled in the Engine section of game.project
|
|
-- Can be coupled with fixed updates of the physics simulation if 'Use Fixed Timestep' is enabled in
|
|
-- Physics section of game.project
|
|
-- Add update code here
|
|
-- Learn more: https://defold.com/manuals/script/
|
|
-- Remove this function if not needed
|
|
end
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
-- Add message-handling code here
|
|
-- Learn more: https://defold.com/manuals/message-passing/
|
|
-- Remove this function if not needed
|
|
end
|
|
|
|
function on_input(self, action_id, action)
|
|
-- Add input-handling code here. The game object this script is attached to
|
|
-- must have acquired input focus:
|
|
--
|
|
-- msg.post(".", "acquire_input_focus")
|
|
--
|
|
-- All mapped input bindings will be received. Mouse and touch input will
|
|
-- be received regardless of where on the screen it happened.
|
|
-- Learn more: https://defold.com/manuals/input/
|
|
-- Remove this function if not needed
|
|
end
|
|
|
|
function on_reload(self)
|
|
-- Add reload-handling code here
|
|
-- Learn more: https://defold.com/manuals/hot-reload/
|
|
-- Remove this function if not needed
|
|
end
|