![]() |
|
Animation not displaying |
CursedTyrant
Member #7,080
April 2006
![]() |
Does anyone see a reason why this code:
wouldn't work? The rectfill is displayed, so the object exists and works fine (even moves Here's some other stuff:
If I do this in main: CAnim *anim = new CAnim(ANIM_ENEMY_FIRE_MOVE, 300, SCREEN_H-160, 64, 5.0f); ... //game loop if (anim) { anim->Play(); } //game loop ... Note that both enemy.cpp and main.cpp use the same global ANIM_ENEMY_FIRE_MOVE, and while it works fine in main and in cube.cpp, it does not work in enemy.cpp. It's probably something stupid, but I just can't see it. --------- |
Kris Asick
Member #1,424
July 2001
|
I think you're simply forgetting to call the Play() function. If that's not it, I'll take a closer look, but that's the only difference I saw at first glance. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
CursedTyrant
Member #7,080
April 2006
![]() |
Quote: I think you're simply forgetting to call the Play() function. DrawFrame() does the same as Play(), and they both don't work in enemy.cpp, but work perfectly fine elsewhere. Frame 0 is not empty. --------- |
Kris Asick
Member #1,424
July 2001
|
Try setting up copy constructors for your classes and see if that helps. The only thing I can think of at the moment is that you're losing data because it's not being reallocated properly when you add items to your vectors. (I found out while first using vectors a couple months ago that certain allocations of memory might be lost, especially with Allegro objects, if you don't manually handle them in a copy constructor when using vectors of objects instead of vectors of pointers, but without seeing more code I can only guess if this is the case.) --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
CursedTyrant
Member #7,080
April 2006
![]() |
Would this [cursedtyrant.freshsite.pl] be enough? --------- |
Kris Asick
Member #1,424
July 2001
|
Well, I get an invalid page fault when I try to run your program so something's up, and it's likely related to memory or vector handling. EDIT: Actually, the crash was my bad. I fixed it and got the program running. I see what you mean now... let's see... continues messing with it EDIT: You're gonna kick yourself when I tell you what the problem is... You are loading the enemy before you load the animations the enemy runs off of. As a result, when the enemy sets up its animation, it creates an empty (but still valid) animation object. Since the object exists, the Move object points somewhere, but it doesn't have anything in it because the animation that was supposed to go into it wasn't loaded when the enemy was created! Move the line in your initialization routine that creates the enemy to after the animation loading and you should be fine. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
CursedTyrant
Member #7,080
April 2006
![]() |
Quote:
EDIT: You're gonna kick yourself when I tell you what the problem is...
Aye... This was a stupid mistake... I couldn't see it tough, and I've tried for a day Thanks for your help, I could've never found the problem without it --------- |
|