how to sprite texture offset frame using rand($PT)?
thx all advance!
how to sprite texture offset frame using rand($PT)?
2100 2 2- wei750830
- Member
- 46 posts
- Joined: Jan. 2012
- Offline
- kleer001
- Member
- 55 posts
- Joined: Jan. 2006
- Offline
without seeing your setup my first guess is something like this:
($F + int(fit01(rand($PT),0,23)))%24
That's if you have a sprite loop of 24 frames numbered
sprite.0.jpg
sprite.1.jpg
…
sprite.23.jpg
First you start with $F, that's the frame number. Then you offset it by an integer that is made by fitting the 0-1 range you get from the rand() expression into a 0-23 range. Finally you take all of that and modulus it by 24 (modulus function gives you the remainder when you divide by that number).
Beware that using $PT will use the point number and if your point count changes then most likely all the point numbers will change. There's ways around that, but it depends on your setup.
($F + int(fit01(rand($PT),0,23)))%24
That's if you have a sprite loop of 24 frames numbered
sprite.0.jpg
sprite.1.jpg
…
sprite.23.jpg
First you start with $F, that's the frame number. Then you offset it by an integer that is made by fitting the 0-1 range you get from the rand() expression into a 0-23 range. Finally you take all of that and modulus it by 24 (modulus function gives you the remainder when you divide by that number).
Beware that using $PT will use the point number and if your point count changes then most likely all the point numbers will change. There's ways around that, but it depends on your setup.
“If you can eat it raw you can't under cook it”
- wei750830
- Member
- 46 posts
- Joined: Jan. 2012
- Offline
-
- Quick Links