@Raiuc wrote:
I'm using ofxMSAInteractiveObject from @memo in oF 0.9.8
I have several instances of ofxMSAInteractiveObject, each one with some button, logo, or arrow:logo.load("myLogo.png"); logoGUI.content = &logo; logoGUI.set(100, 100, 400, 250);
The program changes what is drawn according to an int global variable called state, but I don't know how to deactivate instances of ofxMSAInteractiveObject in each state, because once I set an instance it's drawn forever in the app.
In fact, once the object is set and an image is assigned, the object is drawn into the app, but I don't even call its draw() method! I don't know how to prevent the program to draw it.What I'm doing now is to call a method to set the content of unused objects to NULL in each state and set their coordinates to zero as well as the width and height; but this is not elegant, it's a lot of code, I need to create dozens of states; I'm sure there's another easier way.
This is the class for my buttons:
#pragma once #include "ofxMSAInteractiveObject.h" class interactiveUI : public ofxMSAInteractiveObject { public: ofBaseDraws *content; interactiveUI() { content = NULL; } void setup() { enableMouseEvents(); enableKeyEvents(); } void exit() { } void update() { } void draw() { if(content) { width = content->getWidth(); height = content->getHeight(); content->draw(x, y, width, height); // add a border if mouse is pressed or over the object if(isMousePressed()) { ofNoFill(); ofDrawRectangle(x, y, width, height); } else if(isMouseOver()){ ofNoFill(); ofDrawRectangle(x, y, width, height); } } } };
Any hint will be appreciated.
Thank you.
Posts: 1
Participants: 1