NobleEngine
NobleEngine copied to clipboard
Support creation of a NobleSprite with an existing image or animation
Solving #13
In addition to creating a NobleSprite
with a path to an image or spritesheet, this PR adds the possibility of creating a NobleSprite
by giving supplying the function with:
- An image object (
Graphics.image
) - An animation object (
Noble.Animation
)
This enables caching an image or spritesheet and then using it to instantiate several NobleSprite
without loading it from disk everytime. You can now do:
-- Instantiate sprite with an image
local myImage = Graphics.image.new("path/to/image")
mySprite1 = NobleSprite(myImage)
mySprite2 = NobleSprite(myImage)
as well as
-- Instantiate sprite with an animation
local myAnimation = Noble.Animation.new("path/to/spritesheet")
myAnimation:addState("default", 1, animation.imageTable:getLength(), nil, true)
mySprite1 = NobleSprite(myAnimation)
mySprite2 = NobleSprite(myAnimation)
I had to rename the __imageOrSpritesheet
parameter to reflect these changes, and didn't think __imageOrSpritesheetOrAnimation
was super catchy, so ended up opting for __view
. The inline documentation has also been updated to detail these new usecases and show usage
"View" is a good term for this, and a familiar one from my days using Flash libraries, so I agree that's the right name for this variable/argument as it expands to become a somewhat more generic object.
Finally got around to getting a proper look at this. Sorry for the delay. Fantastic work! A wonderful upgrade to NobleSprite.