I’m trying to make a simple system where when the sword touches “Enemy” the enemy sends a message to “Enemy Heath Bar” which then plays an animation based on the state of the current “Enemy_Heath”, but it doesn’t work. Btw I did get collision messages from the consol prior to adding the messaging code.
The Enemy Heath Bar code:
Enemy_Heath = 2
function on_message(self, message_id, message)
if message_id == "Damage" and Enemy_Heath == 2 then
sprite.play_flipbook("/Enemy Heath Bar", ("Enemy Heath Bar 1"))
Enemy_Heath = 1
else if message_id == "Damage" and Enemy_Heath == 1 then
sprite.play_flipbook("/Enemy Heath Bar", ("Enemy Heath Bar 2"))
Enemy_Heath = 0
end
The Enemy Code:
function on_message(self, message_id, message, sender)
if(message_id == hash("contact_point_response"))
and message.other_group == hash("Sword") then
msg.post("/Enemy Heath Bar", "Damage")
end
end