Trouble making a flash effect

Hello everyone, I am having some trouble implementing a simple flash-like effect I created for my health bar. 

You see, the code for my health bar’s implementation, the health bar itself, and the health bar’s updating are all in different files hence making this very difficult.

--healthbar.lua (actual healthbar creation) function M.update() transition.to(myCurrentHealthBar, {alpha = 1, time = 500}) transition.to(myCurrentHealthBar, {alpha = 0.5, time = 1000, delay = 500}) end --asteroid.lua (healthbar updating) asteroidCollision = function(self, event) local other = event.other local phase = event.phase local mRand = math.random if phase == "began" then if other.id == "bullet" or other.type == "ship" then if other.canBeHit then other.health = other.health - self.damage other.healthbar.update() end self.health = self.health - other.damage if (self.health \<= 0) then explosion.new(self.parent, self.x, self.y, 1, 1, mRand(-10, 10), mRand(-10, 10)) display.remove(self) end end end end --ship.lua ship.healthbar = healthbar.new(group, ship)

Currently, when I run this code a get a nil value error, which I was sort of expecting. I thought about returning the components of the health bar but since there are more than one I can’t return them both. Any help would be great, thanks!

I don’t see healthbar.lua code so it is hard to me tell what you should do.

I would use structure of module for healthbar like this:

local M = {} function M.new ( options ) &nbsp; &nbsp; ... &nbsp; &nbsp; local group = display.newGroup() &nbsp; &nbsp; -- Create visual part of&nbsp;healthbar here and add them to group object &nbsp; &nbsp; &nbsp; &nbsp; function group:flash() &nbsp; &nbsp; &nbsp; &nbsp; -- I think you should put transitions&nbsp;here or whatever you want &nbsp; &nbsp; end &nbsp; &nbsp;return group end return M

I use structure similar to that used in Ponywolf free games for Corona.

ldurniat 

There is something you’re passing to json.decode() that’s not valid. Perhaps printing the string you get from the notification might provide some insight.

I don’t see healthbar.lua code so it is hard to me tell what you should do.

I would use structure of module for healthbar like this:

local M = {} function M.new ( options ) &nbsp; &nbsp; ... &nbsp; &nbsp; local group = display.newGroup() &nbsp; &nbsp; -- Create visual part of&nbsp;healthbar here and add them to group object &nbsp; &nbsp; &nbsp; &nbsp; function group:flash() &nbsp; &nbsp; &nbsp; &nbsp; -- I think you should put transitions&nbsp;here or whatever you want &nbsp; &nbsp; end &nbsp; &nbsp;return group end return M

I use structure similar to that used in Ponywolf free games for Corona.

ldurniat 

There is something you’re passing to json.decode() that’s not valid. Perhaps printing the string you get from the notification might provide some insight.