When I bundle or build my project to HTML5 or windows, for some reason, only the default animation plays. It works fine when I build in testing and they play alright, but whenever I attempt to export the animations do not play nor do I get any errors. The script I have for handling the movement and animations for the player sprite is here.
local BASE_VELOCITY = 100
function init(self)
--msg.post("camera", "follow", { target = hash("/Main Character"), lerp = 0.7, horizontal = true, vertical = true, immediate = true })
msg.post("#", "acquire_input_focus")
self.keypress = {
up = false,
down = false,
left= false,
right=false
}
self.velocity = vmath.vector3(0,0,0)
self.correction = vmath.vector3()
go.set_position(vmath.vector3(222,(Height)*64,0))
end
function update(self,dt)
self.correction = vmath.vector3()
end
function fixed_update(self, dt)
local pos = go.get_position()
pos = pos + self.velocity * dt
go.set_position(pos)
self.velocity.x = 0
self.velocity.y = 0
end
function final(self)
-- Add finalization code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function walkLR(self, Direction)
self.velocity.x = BASE_VELOCITY * Direction
end
function walkUD(self, Direction)
self.velocity.y = BASE_VELOCITY * Direction
end
function on_message(self, message_id, message, sender)
-- Handle collision
if message_id == hash("contact_point_response") then
-- Get the info needed to move out of collision. We might
-- get several contact points back and have to calculate
-- how to move out of all of them by accumulating a
-- correction vector for this frame:
if message.distance > 0 then
-- First, project the accumulated correction onto
-- the penetration vector
local proj = vmath.project(self.correction, message.normal * message.distance)
if proj < 1 then
-- Only care for projections that does not overshoot.
local comp = (message.distance - message.distance * proj) * message.normal
-- Apply compensation
go.set_position(go.get_position() + comp)
-- Accumulate correction done
self.correction = self.correction + comp
end
end
end
end
function on_input(self, action_id, action)
if action_id == hash("Up") and action.pressed then
self.keypress.up = true
self.keypress.down = false
self.keypress.left = false
self.keypress.right = false
sprite.play_flipbook("#sprite", "Up Walk")
print("walking up")
elseif action_id == hash("Down") and action.pressed then
self.keypress.up = false
self.keypress.down = true
self.keypress.left = false
self.keypress.right = false
sprite.play_flipbook("#sprite", "Down Walk")
sprite.set_hflip("#sprite", false)
print("walking down")
elseif action_id == hash("Left") and action.pressed then
self.keypress.up = false
self.keypress.down = false
self.keypress.left = true
self.keypress.right = false
sprite.play_flipbook("#sprite", "Side Walk")
sprite.set_hflip("#sprite", false)
print("walking Left")
elseif action_id == hash("Right") and action.pressed then
self.keypress.up = false
self.keypress.down = false
self.keypress.left = false
self.keypress.right = true
sprite.play_flipbook("#sprite", "Side Walk")
sprite.set_hflip("#sprite", true)
print("walking Right")
end
if self.keypress.up and action_id == hash("Up") and action.released then
self.keypress.up = false
sprite.play_flipbook("#sprite", "Up Idle")
elseif self.keypress.down and action_id == hash("Down") and action.released then
self.keypress.down = false
sprite.play_flipbook("#sprite", "Down Idle")
elseif self.keypress.right and action_id == hash("Right") and action.released then
self.keypress.right = false
sprite.play_flipbook("#sprite", "Side Idle")
elseif self.keypress.left and action_id == hash("Left") and action.released then
self.keypress.left = false
sprite.play_flipbook("#sprite", "Side Idle")
end
if self.keypress.right and action_id == hash("Right") then
walkLR(self, 1)
elseif self.keypress.left and action_id == hash("Left")then
walkLR(self, -1)
elseif self.keypress.down and action_id == hash("Down") then
walkUD(self,-1)
elseif self.keypress.up and action_id == hash("Up") then
walkUD(self, 1)
end
end