I suppose the object shifted to the right as well as display some animation. However it only move without any animation at all (instead it display one still image somewhere in the middle of the sequences)
[import]uid: 40631 topic_id: 7807 reply_id: 307807[/import]
for a start i would move the require(“movieclip”) line above the function new(). no need to keep requiring it every time you create a new object
as for your problem, it appears your enterFrame function is overriding the enterFrame function for the movieclip hence it moves x=x+1 but doesnt animate (since you killed the play function.
just working out a fix… [import]uid: 6645 topic_id: 7807 reply_id: 27733[/import]
in movieclip.lua [lua]function g:enterFrame( event )
self:repeatFunction( event )
– add a new event
local event = { name=“mcEnterFrame”, target=self}
self:dispatchEvent(event)
end[/lua]
then in your main file
[lua]module (…,package.seeall)
local movieclip = require (“movieclip”)
function new ()
imageSeq = {}
for i=1,6 do
table.insert (imageSeq,“cube”…i…".png")
end
local obj = movieclip.newAnim (imageSeq)
function obj:mcEnterFrame(event)
self.x=self.x+1
end
function obj:start ()
self:play{startFrame=1,endFrame=6,loop=0}
– listen for new event
self:addEventListener(“mcEnterFrame”,self)
end
return obj
end[/lua]
it works but i’m still trying to work out how to avoid having to dispatch a new event
but i’ve checked it with 2 rectangle instances for example and it works fine [import]uid: 6645 topic_id: 7807 reply_id: 27738[/import]
It works like a charm now. Thank you for both the overriding tip and the multiple-instance test [import]uid: 40631 topic_id: 7807 reply_id: 27758[/import]
ah, glad to hear that. had me stumped for a while. i tried storing the old enterframe, redefining it and then calling the old one in the new one but that just broke it. I am still wondering if there is a neater method and will look into it.
anyway i don’t think my solution for now has much affect on performance, so it should be fine, i’m just interested in other solutions to see what’s possible
[import]uid: 6645 topic_id: 7807 reply_id: 27774[/import]