ó Ø function init(self) msg.post(".", "acquire_input_focus") self.speed = 3000 self.jump_force = vmath.vector3(0, 1600, 0) self.on_ground = false self.move = 0 end function update(self, dt) local pos = go.get_position() if pos.x < -55 then pos.x = -55 end if pos.x > 950 then pos.x = 950 end go.set_position(pos) self.on_ground = false end function fixed_update(self, dt) if self.move ~= 0 then local force = vmath.vector3(self.move * self.speed, 0, 0) msg.post("#collisionobject", "apply_force", { force = force, position = go.get_position() }) end end function on_input(self, action_id, action) if action_id == hash("left") then if action.pressed then self.move = -1 sprite.play_flipbook("#sprite", hash("run_left")) elseif action.released then self.move = 0 sprite.play_flipbook("#sprite", hash("still_left")) end elseif action_id == hash("right") then if action.pressed then self.move = 1 sprite.play_flipbook("#sprite", hash("run_right")) elseif action.released then self.move = 0 sprite.play_flipbook("#sprite", hash("still_right")) end elseif action_id == hash("jump") and action.pressed and self.on_ground then msg.post("#collisionobject", "apply_force", { force = self.jump_force, position = go.get_position() }) end end function on_message(self, message_id, message, sender) if message_id == hash("contact_point_response") then if message.normal.y > 0.7 then self.on_ground = true end end end @main/player2.0.script"