I guess my current task is to create a new sprite that has properties values so that when i collide with it, i can read/take the “egg.properties.health”. right now, if i collide with an object that does not have egg.properties I crash out and get "attempt to index field ‘properties’ (a nil value).
If there is not a way to specify a properties table (like what i pull from Tiled properties) while initially adding the sprite, then is there a different way to do this? a super simple example would be great.
this is what i had with examples and samples:
local poopegg = function()
local eggSheet = graphics.newImageSheet(“egg@2x.png”, {width = 60, height = 60, numFrames = 1})
local sequenceData = {
{name = “idle”, sheet = eggSheet, frames = {1}, time = 1600, loopCount = 0},
}
egg = display.newSprite(eggSheet, sequenceData)
local setup = {
kind = “sprite”,
layer = 3, --adds the player sprite to this layer
locX = 5, --sets the position of the player at tile x location on map
locY = 12, --sets the position of the player at tile y location on map
levelWidth = 60, --the actual width of the player sprite
levelHeight = 60, --the actual height of the player sprite
offsetX = 0,
offsetY = 0,
properties = {
health = 999,
bleh = 30
}
}
mte.addSprite(egg, setup)
I also looked at setObjectProperties(), but would love to have another example if this is the correct approach for setting egg.properties.bleh
Thank you in advance!