drawing a circle at an varable postion?

When I try to draw a circle at a varable postion, the circle dosn’t appear at all.

I’ve tried;

ofCircle( xpos, ypos, mouseY);
and
ofCircle( 250 + xpos, 250 + ypos, mouseY);

if I don’t use the varable, the circle draws without any problems.

I have no complier errors or warning.

do you set xpos or xpos to some initial value?

ie,

in h file:

  
float xpos;  
float ypos;  

in setup():

  
xpos = 100;  
ypos = 150;  

int draw():

  
ofSetColor(255,0,0);  
ofCircle(xpos, ypos, 100);  
  

if you post your code as a zip we can point out the problem.

hope that helps!
zach

Ok, I put the .h and .cpp in a zip.
Also I did set xpos and ypos to an initial value

Openframeworks.zip

Try setting the color before you draw your circle. You may just be drawing a black circle on a black background.

ofSetColor(255,255,255);
ofCircle( xpos, ypos, mouseY);

I found out what was wrong with the code. In testApp.cpp I put “float” before xpos and ypos.

yes, to explain this call:

  
  
//--------------------------------------------------------------  
void testApp::setup(){  
ofBackground(0,0,0);  
float xpos = 250;  
float ypos = 250;  
}  
  

even though you’ve made xpos and ypos variables in the class level (in testApp.h), this make new variables that have the same name for just the setup function (scoped to just that function), so those temporary variables get the 250 values and not the variables you have at the testApp level.

  • zach