Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Sharing variables between classes

$
0
0

Hi guys,

Firstly, I am an oF noob and have been having a hell of a time to pass variables from one class to another. I am trying to pass values from ClassTwo to ClassOne using a pointer. My structure is:

ofApp
-ClassOne
-ClassTwo

So far this is what I have.... simplified:

class ClassOne : public ofxFadeScene {
	
public:
    float theradius;
}

void setup(){}
void update(){}
void draw(){
	
ofSetColor(255, 55, 55);
ofCircle(ofGetWidth()/2, ofGetHeight()/2, theradius);

}

And setting it from ClassTwo with:

ClassOne *c1ptr;

void setup(){
	c1ptr = (ClassOne*)ofGetAppPtr();
}
    
void update{
	c1ptr->theradius = 400;
}

Are pointers even the best way to go at this? Any help appreciated.


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>