#108642 - FireSlash - Fri Nov 10, 2006 8:53 pm
So, heres what I know:
testObject isn't null
this inside testObject isn't null.
But a in spriteController::attachActor is, for some reason, null.
.....*twitch*
_________________
FireSlash.net
testObject isn't null
this inside testObject isn't null.
But a in spriteController::attachActor is, for some reason, null.
.....*twitch*
Code: |
// === spriteController.h
// Sprite controller // manages the OAM // For great justice #ifndef __class_spriteController #define __class_spriteController #include "managedObject.h" #include "actor.h" #include <nds.h> class spriteController: public managedObject { public: bool create(objectManager *instigator); void tick(float deltatime); bool destroy(); // spriteController specific functions void moveSprite(int id, u16 x, u16 y); void rotateSprite(int id, u16 angle); int attachActor(actor *a); void detachActor(actor *a); protected: SpriteEntry *spriteMain; SpriteRotation *spriteRotationMain; int nextID; }; #endif // ===== spriteController.cpp #include "spriteController.h" int spriteController::attachActor(actor *a) { //if (a == NULL) // return 0; int id = nextID++; // HACK Coordinate position; position = a->getLocation(); // CRASHES HERE <<<<------ ;( spriteMain[0].attribute[0] = ATTR0_COLOR_256 | ATTR0_ROTSCALE_DOUBLE | (int)position.y; spriteMain[0].attribute[1] = ATTR1_ROTDATA(0) | ATTR1_SIZE_64 | (int)position.x; spriteMain[0].attribute[2] = id; dmaCopy(a->getGfxLoader()->image()->palette, (u16*)SPRITE_PALETTE, sizeof(a->getGfxLoader()->image()->palette)); dmaCopy(a->getGfxLoader()->image()->data8, &SPRITE_GFX[id * 16], (a->getGfxLoader()->image()->width * a->getGfxLoader()->image()->height)); return id; } // === testObject.h // Object to debug with. #include "actor.h" #include "objectManager.h" #include "spriteController.h" class testObject: public actor { public: bool create(objectManager *instigator); void tick(float deltatime); protected: int counter; }; // === testObject.cpp // Object to debug with #include <nds.h> #include <stdio.h> #include "testObject.h" bool testObject::create(objectManager *instigator) { o = instigator; createGfx("mat.pcx"); o->s->attachActor(this); return true; } void testObject::tick(float deltaTime) { // Do stuff } //===== main.cpp // Includes #include <nds.h> #include <fat.h> #include "objectManager.h" #include "testObject.h" #include "videoController.h" #include "spriteController.h" int main(int argc, char ** argv) { powerON(POWER_ALL_2D); irqInit(); irqSet(IRQ_VBLANK, 0); objectManager manager; manager.create(); // Initialize! // Init fat routines fatInitDefault(); // Create video controller videoController *v; v = new videoController; v->create(&manager); // Sets up vram banks manager.attach(v); manager.v = v; // Create sprite controller spriteController *s; s = new spriteController; s->create(&manager); manager.attach(s); // TEST testObject *test; test = new testObject; test->create(&manager); manager.attach(test); while (1) { manager.manage(); //swiWaitForVBlank(); } return 0; } |
_________________
FireSlash.net