PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Can't get animation when loading from package

Nothing more to say...

I'm loading a bitmap with a loop animation (16 frames).

When loading the file normally i can get the animation to work.

This section of code works:

Code:
Anim$ = LoadSprite (AppPath$ + "//graphics//"+ "anim.bmp", G_RGB(255, 0, 255), 17, 100, NULL);
SETSPRITEx (anim$, 30);
SETSPRITEy (anim$, 220);
SetSpriteLight(anim$, 255);
SETSPRITEFRAMES (anim$, 0, 16, -1,0 );


But, the animation won't work (i.e.:i can see the sprite, set x position, y position, light radius ecc..) if I load the same file stored in a package with this code:

Code:

p$ = OpenPackage(AppPath$+"//graphics//"+"Graphics.pak", "MyPrivateKey");

fn$ = ExtractFileFromPackage(p$, "anim.bmp");
anim$ = LoadSprite (fn$, G_RGB(255, 0, 255), 1, 0, NULL);
deleteFile(fn$);

ClosePackage(p$);

SETSPRITEx (anim$, 30);
SETSPRITEy (anim$, 220);
SetSpriteLight(anim$, 255);
SETSPRITEFRAMES (anim$, 0, 16, -1,0 );



I've also noted that files loaded from packages are "case sensitive" : anim.bmp is not the same as Anim.bmp

I'm getting those errors under 0.9.6 but the same thing appens on 0.9.7.

Am I doing something wrong? Please, I'm in serious need of help, since I'd like to pack the resources for my program.

Update:
After inserting this line:
Code:
SETSPRITEANIMSPEED (anim$, 256)

after the SETSPRITEFRAMES command, i'v obtained something new: the sprite started blinking at regular intervals, just like it was formed by a single frame containing pictures plus 15 empty frames. Maybe a screen update problem? Gonna check the sprite drawing process.
Could it be that you are not defining the size of the frames in your LoadSprite() after the ExtractFileFromPackage() ?

Use the same line:

Code:
Anim$ = LoadSprite (fn$, G_RGB(255, 0, 255), 17, 100, NULL);


You need to define the size of each frames and how many frames the sprite contains at the loading time.

This will solve your problem.
THANKS!

Problem solved.... I get lost in a glass of water...

This code now works:
Code:

p$ = OpenPackage(AppPath$+"//graphics//"+"Graphics.pak", "MyPrivateKey");

fn$ = ExtractFileFromPackage(p$, "anim.bmp");
anim$ = LoadSprite (fn$, G_RGB(255, 0, 255), 17, 100, NULL);
deleteFile(fn$);


ClosePackage(p$);

SETSPRITEx (anim$, 30);
SETSPRITEy (anim$, 220);
SetSpriteLight(anim$, 255);
SETSPRITEFRAMES (anim$, 0, 16, -1,0 );




Bye, Solonn.