I can't seem to figure this out. I'm trying to place a grass sprite that contains three "levels" of grass. It's all for effect, non-interactive graphics. I do it this way:
System, On start of layout: Function, Call "PlaceGrass"()
Function, On "PlaceGrass"
--System, Repeat 600 times: System, Create object Sprite on layer 0 at (random(0,WindowWidth),random(0,WindowHeight))
Sprite, On created: Sprite, Set animation frame to random(0,2)
Yet when I run the code it sets the grass sprite like I want, but the frames are all the same. Could anyone help me out with this? Thank you in advance.
Make sure your Animation speed is set to 0 on the Default animation. Also use int(random(0,3)).
You also don't need "Sprite, On created: Sprite, Set animation frame to random(0,2)", you can put just "Sprite, Set animation frame to random(0,2)" under the "create object" line.
Develop games in your browser. Powerful, performant & highly capable.
Yeah I've tried both things and neither worked. I have tried quite a bit of options and nothing seems to isolate each one on their own. Look under "FloraGen" event sheet.
It is working! (Change the 2 to a 3 like I said though). The problem is your frames 1 & 2 are so close in colour to the background you can't see them. Change your background and you'll see the other grass is there.
No 0,2 is correct there are 3 frames and its zero count based therefore 0,1,2 are the frames you want to pick from
From the manual:
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
ok that might be right idk I normally use Round(random(x,y) or floor, ect i havent used just random in awhile i thought it would
Awesome, thanks guys! After looking at it the grass sprites seem kind of bleh. I can't believe I didn't think about the colors being too close!!!
Edit: I changed the number of times it runs (down to 150) and the graphics look fine. I had it doing it too often that it was all globbed together in a mess. But again, thanks guys!