0

draw(...) メソッドの curWaitTime 変数にアクセスできません。EXC_BAD_ACCESS エラーでクラッシュします。動的に割り当てさえされていません!

#include <string>
#include "ofMain.h"
#include "Colour.h"
#include "ColourScheme.h"

#define NOTIFICATION_TEXT_SIZE          60
#define NOTIFICATION_FADE_OUT_TIME      2

class Notification {
private:
    char *text;
    float curWaitTime;

    void setGlColour( Colour *colourScheme, int colourType, float alphaPercentage ) {
        glColor4f( colourScheme[colourType].r,
                  colourScheme[colourType].g,
                  colourScheme[colourType].b,
                  colourScheme[colourType].a * alphaPercentage );
    }

public:
    float screenWidth, screenHeight;

    Notification( const char *_text, float width, float height  ) {
        text = new char[255];
        strcpy(text, _text);
        screenWidth = width;
        screenHeight = height;
        curWaitTime = NOTIFICATION_FADE_OUT_TIME;
        NSLog(@"Notification created!");
    }

    ~Notification() {
        delete text;
    }

    bool draw( Colour *colourScheme, ofTrueTypeFont *font, float deltaTime ) {
        // update timer
        curWaitTime -= deltaTime;
        if( curWaitTime <= 0.f ) {
            return false;
        }

        //draw
        setGlColour( colourScheme, COLOUR_BACKGROUND_COL3, curWaitTime / NOTIFICATION_FADE_OUT_TIME );
        font->drawString(text, screenWidth/2 - (font->stringWidth(text)/2), screenHeight/2);

        return true;
    }
};

それは本当に私を混乱させます、これは通常うまくいきます。何か案は?XCode を使用し、OpenFrameworks で iOS 用のコーディングを行っています

4

0 に答える 0