What is a good way to randomize frames of an object but the randomized frame is the same among all instances of an object?
Set sprite animation frame to floor(random(sprite.animationframecount) to change them all to the same random frame.
If you want to set a random order of frames, use the advanced random plugin's permutation table.
Develop games in your browser. Powerful, performant & highly capable.
I tried that but it strangely didn't work.
You want the frame to be the same for all instances? Then assign it to a variable:
set r to random(sprite.animationFrameCount)
Sprite set frame to r
Weird, its still not working out for me. I could try it by randomizing the variable number and have the number of a variable = each frame. But I have over 100 frames I want to randomize so that might be very time consuming. Do you know of any other method I could use that's fast?
Can you explain the task?
Do you need to set one random frame to all instances? (say, frame 4 for all)
Or random frames to each instance, without repetition?
I'm trying to make a background that changes each time the game starts. So I'm using multiple sprites to represent the background so I want each instance to be the same frame when randomly picked!
Then setting a random value to a variable should definitely work.
On start of layout: Set r to random(sprite.animationFrameCount) Sprite set frame to r
Maybe I am misunderstanding.
No, r should be a global or a local variable, not instance variable.
Finally figured it out thank you so much!