Hello everyone,
I am all new to defold and would need some help.
I am working on an top shooter and wants my ship to follow my mouse/touch but it don’t works as i want. I was trying to cap the movement so it wouldn’t go outside the screen but my if wont work. And my other problem is that if i touch somewhere on the screen the ship jumps to that position i want it to move from where it is. Hope you understand=)
function init(self)
msg.post(".", "acquire_input_focus")
self.pos = go.get_position()
end
function update(self, dt)
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.dx then
local pos
if action.dx > 0 or action.dx < 640 then
pos = vmath.vector3(action.x, 150, 0)
end
if pos ~= nil then
go.set_position(pos)
end
end
end
Thanks
/Isak