Class not working - what am I doing wrong?

I thought I made this class right, but it appears not to be working:

static int BACK_COLOR = 255;

Shape square;

void setup(){ size(700,500); stroke(0); background(BACK_COLOR); square = new Shape(); }

void draw(){ background(BACK_COLOR); }

class Shape{ public Shape(){ float x = 0; float y = 0; boolean controlling = false; boolean isJumping = false; } void move(int move_X,int move_Y){ if(controlling){ x+=move_X; y+=move_Y; } } }

Every time I try to compile, it says "Cannot find anything named 'controlling'"

Tagged:

Answers

  • edited June 2015 Answer ✓

    Variable controlling was declared inside Shape's constructor.
    Therefore it is locally scoped there only and ceases to exist once constructor finishes!

Sign In or Register to comment.