Как заметил Разонг, это не то, как ОФ работает. OF (насколько мне известно) предоставляет удобную оболочку для многих вещей OpenGL. Таким образом, вы должны использовать вызовы OF для воздействия на текущий контекст рисования (в отличие от представления холста со спрайтовыми объектами или чем-то еще). Я обычно интегрирую такие вещи в свои объекты. Допустим, у вас есть такой класс ...
class TheBall {
protected:
ofColor col;
ofPoint pos;
public:
// Pass a color and position when we create ball
TheBall(ofColor ballColor, ofPoint ballPosition) {
col = ballColor;
pos = ballPosition;
}
// Destructor
~TheBall();
// Make our ball move across the screen a little when we call update
void update() {
pos.x++;
pos.y++;
}
// Draw stuff
void draw(float alpha) {
ofEnableAlphaBlending(); // We activate the OpenGL blending with the OF call
ofFill(); //
ofSetColor(col, alpha); // Set color to the balls color field
ofCircle(pos.x, pos.y, 5); // Draw command
ofDisableAlphaBlending(); // Disable the blending again
}
};
Хорошо, круто, я надеюсь, что это имеет смысл. Теперь с этой структурой вы можете сделать что-то вроде следующего
testApp::setup() {
ofColor color;
ofPoint pos;
color.set(255, 0, 255); // A bright gross purple
pos.x, pos.y = 50;
aBall = new TheBall(color, pos);
}
testApp::update() {
aBall->update()
}
testApp::draw() {
float alpha = sin(ofGetElapsedTime())*255; // This will be a fun flashing effect
aBall->draw(alpha)
}
Счастливого программирования.
Удачного проектирования.