Hello Of users!
Completely new to OF, I am testing basic class inheritance. (By the way, thank you for this OfBook projet which is a great tool)
I would like to extend the ofNode class to take advantage of its postionning methods.
Here is a basic example of an inherited class called “element”
element.h
#pragma once
#include "ofMain.h"
class element: public ofNode {
public:
float posX, posY, posZ;
void setup(float px, float py, float pz);
void customDraw();
element();
};
element.cpp
#include "element.h"
element::element(){}
void element::setup(float px, float py, float pz){
posX = px;
posY = py;
posZ = pz;
this->setPosition(posX, posY, posZ);
}
void element::customDraw(){
ofDrawBitmapString(ofToString(this->getX()), 20, 20);
}
in ofApp.h:
element myElement;
in ofApp.cpp:
void ofApp::setup(){
myElement.setup(100, 200, 0);
}
//--------------------------------------------------------------
void ofApp::draw(){
myElement.customDraw();
}
This code compiles but I get an EXC_BAD_ACCES when calling any of the base class member functions.
In this example, the warning occurs next to the onPositionChanged() in ofNode.cpp
Can I ask you what I am doing wrong?
Thanks.