richmond62 wrote: ↑Wed Feb 21, 2024 12:05 pm
Personally I find there is less opportunity for fine-grained control with an animated GIF than with some sort of frame and a series of either GIF or PNG images.
With Animated GIF you can have the same sort of fine grain control you can have over separate image files/pixel data in separate image controls. If you don't need fine control, like use cases where you just want a progress indicator or a spinner that animates on its own while your script does something else.
PNG is fully 24bit color (RGB+Alpha so actually 32bits) and so it looks nicer, but there are actually a few other advantages to using
Animated GIF over separate GIFs and GIF over PNG files too:
- Animated GIFs aren't separate, that's an advantage when it come to sprites. You want them together and in a certain visual / chronological order, you don't want a single frame to accidentally get deleted and suddenly your sprite's tough-guy walk is now a dandy skip! In my opinion it's just way more convenient to have all ani frames encapsulated in a single file.
- GIF format is NOT RGB, it's index color, which means you can change the colors of a GIF Frame AND every other frame that uses the same color table (often there's only one color table per file) by altering that color table, so for example you could change some colors of Player1's Sprite lets say Red, to make a Player2's sprite that's Blue from the same pixel data just by swapping the color table with another color table. If I remember correctly you can do that with OXT Engine using the 'set the colorMap to colorsList' to apply a color table, then copy the image data (or the image text) to make a permanent copy of the modified image. I was playing around with that sort of thing back when I started to check out 'Decker', since I needed images to have a 1980s MacII 16-color color table for that.
- GIF Format is smaller than PNG, sure it doesn't have good color fidelity but that index color version is a much smaller amount of data. It also supports lossless compression (and that's no longer patent hindered) and there is a version of the format that only stores updated regions for each consecutive frame from the previous frame (it can look like motion trails when they overlap).
Size of the data might not seem important when you only have a few frames you're animating, but I was just playing around with an Isometric Sprite set, where I have 20 frames of walk animations for 8 different directions. That would be 160 separate images (and the set actually includes 16 directions, but I didn't need all of that). I made a combined Animated GIF for each direction, so I had 8 image controls on my card instead of 160 or more. I haven't even added any of the other actions the sprite can do yet (jump, rest, kick, upper attack, etc.). With a GIF the 160 frames. all together are under 2Mb, vs. the original sprite sheets PNG file that I sliced them from that are
way more data, more than 50MB!
- GIF is a simple chunk format (RIFF) container, and it's the older format designed for much harsher hardware limitations, compatible with much older computers (1980s). I can view an Animated GIF with just about anything, a browser, right in the Finder / File Mmanager, in a forum post , or email, etc.
I suppose you could use animated PNG (.APNG) format too. It was intended as a better (and patent free) alternative animated file format, but I don't think there is a lot of software supports that format because it was never truly embraced by the general public.
- Animated GIF allows for the engine to automatically cycle through the frames at steady intervals, you still have control with properties:
repeatcount says how many times the gif should loop the animation (natively, so to have it play once set the repeatcount to 1), to allow it to loop continuously set this to -1
framecount returns the number of frames in the GIF.
currentframe is the currently showing frame
Animated GIF will keep iterating through frames
while you're moving it with the move command, without having to script that part.
Which is great if you just want to quickly test out an animation while syncing it to directional controller input, you can add finer control over some individual frame's rates later (you can even do that in a Animated GIF format using an external GIF Editor (I have some ideas about fixing that need for external app)
Code: Select all
set the repeatcount of image "imagename" to - 1 -- loop forever
move image "imagename" from the loc of image "imagename" to the loc of this card in 200 millliesocnds
-- stop looping:
set the repeatCount of image "imagename" to 0
set the currentFrame of image 1 to the framecount of image 1 -- display to last animation frame
With currentFrame and framecount, you can manually iterate over the frames, set image control to show whatever cel/frame of the GIF you want.
Manually iterate currentframe:
Code: Select all
repeat with i = 1 to the framecount of image "imagename"
set the moveSpeed to 128 -- distance in pixels to move per second
set the currentframe of image 1 to i
wait 100 milliseconds with messages -- adjust this number as needed to get the frame rate desired
end repeat
moveSpeed - distance in pixels to move the object / per second
And you can play around with judicially placed Lock Screen, lock moves, unlock screen, unlock moves moves to try to sync multiple moves / animations. I'm still trying to figure that out.
As far as general animation concerns, it seems that changing some other timing related Engine properties like idleRate can sometimes help or at least make some difference with timing issues.
set the idleRate to 500 -- one idle message per half second
-- The idleRate is an integer between zero and 65535.
-- By default, the idleRate property is set to 200 (one-fifth of a second).
set the repeatRate to xxx milliseconds
-- for scrollbar buttons repeat rate
set the syncRate to tNumber - how often the display is updated during visual effect, drag, and move commands.
Decreasing the syncRate reduces the load on the system, but may make the display of movements and visual effects more jerky. Increasing the rate may help jerky movements (but increases the CPU load. The default value of syncRate is 20.
There's the
effectRate property that specifies how long a very slow visual effect takes, but may effect other screen updating.
There's
acceleratedRendering ad related properties, which may or may not use the GPU depending on the platform:
set the compositorType of this stack to "software" -- options are: none | software | coregraphics | OpenGL
set the acceleratedRendering of stack to true -- or false
set the compositorTileSize of stack to 128 -- 128x128 pixel tileSize
set the compositorCacheLimit of this stack to 8388608 -- 8Mb
Setting
LayerMode to dynamic, scrolling or container may or may not help
set the layerMode of image "background" to "dynamic" -The object is dynamic and subject to change and/or movement.
Other options for layerMode are:
static - (default) The object is static and does not move or change.
scrolling - Applies to groups only and is used where the group contains contents to scroll. The group must be unadorned or the layerMode is set to 'dynamic' (no borders, no scrollbars).
container - Applies to groups only and is used where the group is intended only to organise or restrict the visible area of its contents. The group must be unadorned or the layerMode is set to 'dynamic' (no borders, no scrollbars).