Such an old thread, however is the only thing that I have found that could answer my question. I have 1000s of grass sprites around my map of which have 20 frames each to sway in the wind. The lag is unbearable, I cannot continue. The only way around this is to use Tiled Backgrounds. But I cannot due to not being able to animate them.
I think I have found the solution here, but I do not understand your instructions Yann as I am still very young in Construct3. This problem of animating tiled backgrounds is the only thing stopping me from purchasing a personal license. It's preventing me from finishing my game. I could really use some help on this and I am stumped as to why they have not allowed us to actually animate our tiled backgrounds. It is such a vital feature that is lacking.
I do hope you can reply, in the mean time I am going to try and replicate what you have said and try get something working.
I have a math counter of which depending on the number spawns a sprite. This sprite has 20 frames of grass swaying in the wind. During the game depending on how much it rains, the weather and season new grass will spawn, at any time there can be 1000s, but the lag is unbearable and not possible. The only way that I can fix this lag is to find a way to have tiled backgrounds do exactly what the sprite is doing, minus the lag of course!
nah you're doing it wrong
first you don't use dt in the wait as it's already in seconds
seconds don't create and destroy but toggle visibility
third, well you might have the free version, but I'd use families to make things more code friendly (:
Also I would use a timer variable something like
Global number speed = 5 //frame by second
Global number t=0 //timer variable
Global number frameCount=3 //number of "frame" for the effect
Every tick
-> add to t speed*dt
-> tiledbg1: set invisible
-> tiledbg2: set invisible
-> tiledbg3: set invisible
int(t)%frameCount = 0
-> tiledbg1: set visible
int(t)%frameCount = 1
-> tiledbg2: set visible
int(t)%frameCount = 2
-> tiledbg3: set visible
[/code:1x009smv]
With family (myTiledBG), I would add a family variable named 'frame' of type number and manually set for each tiledBG in the family a number repr?senting the frame.
And then in event it would look like
[code:1x009smv]Global number speed = 5 //frame by second
Global number t=0 //timer variable
Global number frameCount=3
Every tick
-> add to t speed*dt
-> myTiledBG: set invisible
myTiledBG.frame = int(t)%frameCount
-> myTiledBG: set visible[/code:1x009smv]
As for perf, well, there shouldn't be any difference with animated sprite. That's more or less what they do, swapping texture. But yeah you'd have a little bit more object to handle, if it's less than let say 50 frames it should be ok.Yann2012-06-26 21:59:11