Hi guys
I have a movie clip class, which I would like to create in my scene and change it's frame on click.
LightSwitch = Core.class(Sprite)
function LightSwitch:init(x, y, container)
local frames = {}
frames[1] = Bitmap.new(Texture.new("media/lightSwitch.png", true))
frames[2] = Bitmap.new(Texture.new("media/lightSwitchOn.png", true))
frames[1]:setAnchorPoint(0.5, 0.5)
frames[2]:setAnchorPoint(0.5, 0.5)
local mc = MovieClip.new{
{1, 1, frames[1]},
{2, 2, frames[2]},
}
mc.frame = 1
mc:setPosition(x, y)
self:addChild(mc)
container:addChild(self)
end |
I create it inside my scene like this ...
function Scene1:onTransitionInEnd()
self.lightSwitch = LightSwitch.new(160, 160, layerMG)
self.lightswitch:gotoAndStop(1)
end |
.... but I get an error when trying to make it goto frame 1
If anyone can help, that would be awesome!
Thank you in advance!
Comments
self.mc = MovieClip.new...
instead of local mc=...
and then you can do:
self.lightswitch.mc:gotoAndStop(1)
also you can add additional functions to your class which handle this by themselves so you don't deal with the mc directly.
e.g.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: Ninjadoodle
Fragmenter - animated loop machine and IKONOMIKON - the memory game