View Single Post
Old 07 November 2018, 12:38   #161
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,343
Quote:
Originally Posted by amyren View Post
In the docs these commands are mentioned LoadAnim, InitAnim, and NextFrame.
But so far just by adding this line will result in an error meaasage, "unable to free memory"
LoadAnim 0,"images/animtest.iff"
Is there an example of how to do this in a system friendly way?
I don't think the standard animation commands are particularly system-friendly. You could try using the LoadShape command to load the frames if there aren't too many frames, then blitting the frames yourself as needed. Loading large shapes in itself has its own problems however.

I do remember the standard commands working for me many years ago, though it was very picky about the format. Try saving the animation as a different format if possible. Do you have a bitmap set up already? BitmapToWindow can then be used to display the bitmap the animation is rendering to in a window. As previously mentioned, palette information will have to be set for the screen for this to look right.

It might be worth looking at the RIAnim library of commands. I haven't used it, but apparently it supports other animation formats, and seems a bit more useful (uses fast RAM and can blit the animation at any position on a bitmap for example).

Quote:
In my program I have the main program window (window 0) and then I do have several other windows in different sizes that will pop up. But maximum there will be two windows open at once.
So I think I could get away with using only Window 0 and Window 1 used in my program, as long as those extra windows only are used to display text.
Or would this be considered bad practice?
I'm not sure what the relevance of showing text only is. Each window you open needs to have its own ID that's unique to every other window you have open. If you only ever have two windows open, you can use IDs 0 and 1. But if there are lots of different windows your program can handle, that wouldn't be particularly good practice as it can lead to confusion later on. A better approach would be to have a separate ID for each window, regardless of whether other windows are open at the same time. For example, always use ID 0 for the main window, ID 3 for the Preferences window, ID 5 for the Help window, and so on.

Even better practice would be to declare some constants, and use them instead of just numbers for the ID. This will make your code far more readable in the future, and will help to reduce the chances of bugs even further. For example:

Code:
#MainWin = 0
#DebugWin = 1
#PrefsWin = 2
#OutputWin = 5
And then, later on in your program you can use them like this:
Code:
WindowOutput #OutputWin

If EventWindow = #PrefsWin
  NPrint "Prefs Window was used"
End If

Quote:
Then I wonder about the compiler settings. When my program is finished, should one finetune those settings for numbers of objects, windows, anims etc. to fit exactly the number used in the program. Would this reduce the memory requirements for the program?
Not by any amount likely to be worth the time taken to change all the numbers. Basically, each of those items is set up as an array of the possible objects, so reducing the limit reduces the size of the array. But that's only going to be a few hundred bytes at most I suspect, so unless you're desperate for that few bytes (in which case I'm impressed that you're running so close to the limit), I wouldn't bother.
Daedalus is online now  
 
Page generated in 0.04415 seconds with 11 queries