Animate using "change attribute?"
A while ago, it was suggested to use "change attribute" instead of the "animate" behavior & i can't find a good example of how exactly to do that. Does anyone have an idea of how to get that done?
My game has a fair amount of animated elements, so I want to make sure things are as optimized as possible.
My game has a fair amount of animated elements, so I want to make sure things are as optimized as possible.
Comments
Then make a timer: every x seconds (probably around .1) change self.image to self.attribute.image+1.
If that doesn't work, you may have to have an in between step. Have the timer change another self attribute, name it self.animation# for instance, to that+1, then constrain self.image to that attribute.
If that doesn't work, or doesn't make sense for some reason, just let me know, and I'll try to clarify.
Asymptoteell
When actor is touched . . . .
Timer rule after 0.02 seconds change image to image 1.
Timer rule after 0.04 seconds change image to image 2.
Timer rule after 0.06 seconds change image to image 3.
Timer rule after 0.08 seconds change image to image 4.
Etc . . . works well for me and avoids the glitches you can get with 'animate' in certain scenarios.
To be honest it's just a way to get around the animation briefly freezing / glitching when used in conjunction with certain other behaviours / rules, the change image method seems much more robust (far more robust than 'animate) - stabbing my finger/mouse wildly at the actor (when using 'touch, to trigger the animation) as fast as I can causes no problems whatsoever for the change image method, whereas doing this with animate can throw up all kinds of odd little glitches.
I've not tried Asymptoteell's method, but it sounds like it would work just fine too.
at the change of scene the computer √ all calls for display of images; locates them in the Resources files; and loads them into memory …
this includes images displayed in Actors and their behaviors and the changeImage behavior displays an image;
while the changeAttribute self.image is a string … change occurs/image is drawn in runtime. aha! sometimes you have to start with the end condition to get to the beginning! … and computers are supposed to be logical! ;D
you do not need to type in .png … any image in GS is a .png
(0.1 = 6 images/second—FPS; and, 0.15 = 4 FPS)
because the images names are #s and not text … you can manipulate them with the mathematical operants (+/-)
MH
Ace
For animation now, I use animate
Ace
though I still prefer the changeAttribute to changeImage; as believe the images that are on display in a scene, while not preloaded at gameStart, are loaded in memory at sceneStart; and think mayhap images in changeAttribute are not retained in memory (the same appears to be so in animationBehavior.)
also, I use many transparent.png(s) for images outside the cameraSize area with a scene.loadImages boolean controlActor running a timer after 0.5 seconds to change to true; and, on those transparentActors the Rule when that boolean is true changeAttribute self.Image ... seems run faster for large scenes.
MH
"wait, I'm lost. why don't you want to use animate?"
I simply couldn't get certain things to work with animate, for instance when animating something (with 'animate') and also moving the actor (using change attribute) - I didn't seem to have control over which piece of code happened first (the move or the frames completing) so I ended up with all sorts of weird happenings.
I am fully willing to accept that I haven't got a clue what I am doing as I am still learning and still have a ton of stuff to even begin to understand, but after a few hours of wrestling with animate I gave up defeated, but after a couple of minutes with ChangeImage I had what I was after, and it seemed unbreakable (compared to animate) no matter how many crazy clicks and drags and randomness I threw at it it refused to glitch in any way.
And to be honest I've not thought of using Change Attribute . . . . . do you think it would be a better option . . . ?
http://arcade.gamesalad.com/game/3158
I cannot seem to play it anymore as it isn't html5? And I cannot locate it in the Creator any more either. Perhaps they removed all of my demos for some reason?
Anyway, if you can find a way to open it, feel free to dig around in it.
The advantage of using a custom built Animate behavior is the ability to dynamically change the playback speed of the animation at Runtime. You also have the ability of dynamically playing the animation both forwards and reversed, also instantly changeable during Runtime.
If you fiddled with the math a bit, you could also have it play forwards then backwards then forwards, etc. creating a pulsing or rocking effect.
It also used to have the advantage of not preloading the images for iOS causing shorter load times. This appears to have been addressed with the preload art checkbox.
However, not preloading the art is now an issue though with html5, as the remaining frames of animation appear blank until they are loaded in.
If you cannot find the demo I made ( as I am unable to!) just email me and I will send you the file.
Joe
It'd be great though, if the fps was controllable right in the "animate" behavior. That'd be a HUGE improvement.
Depends on what you need, fast load times or a tonne of actors right from the start . . . . I don't know too much about it either, I am still picking up clues from other people's conversations.
Double click an actor in the (top) left panel to get it's attributes window up, you will se the Preload Art option.