objects help December 28, 2009 05:56AM | Registered: 15 years ago Posts: 444 |
enum BUTTON_COLOR{WHITE,RED,BLUE,CYAN,GREEN}; class button{ public: void setMessage(char* m){ strcpy(msg,m); } char* getMessage(){ return msg; } void setLocation(int X,int Y){ x=X; y=Y; } int getX(){ return x; } int getY(){ return y; } void setDim(int w,int h){ width = w; height = h; } int getWidth(){ return width; } int getHeight(){ return height; } void setColor(BUTTON_COLOR c){ color = c; } BUTTON_COLOR getColor(){ return color; } void genImage(); void buttonDraw(); private: int x,y; int width; int height; char* msg; BUTTON_COLOR color; image buttonImg; sprite buttonSpr; }; void button::genImage(){ switch (color) { case WHITE: button::buttonImg.LoadImage(buttonWhite_png); break; case RED: button::buttonImg.LoadImage(buttonRed_png); break; case BLUE: button::buttonImg.LoadImage(buttonBlue_png); break; case CYAN: button::buttonImg.LoadImage(buttonCyan_png); break; case GREEN: button::buttonImg.LoadImage(buttonGreen_png); break; } button::buttonSpr.SetImage(buttonImg); button::buttonSpr.SetStrechWidth(width/31); button::buttonSpr.SetStrechHeight(height/31); } void button::buttonDraw(){ button::buttonSpr.Draw(x,y); }I'm not finished yet, but i wanted to see if my code actually compiled, and it didn't. I've probably got some stupid error that i can't see.
f:/homebrew/buttonTest/source/template.cpp:80: error: 'image' does not name a type f:/homebrew/buttonTest/source/template.cpp:81: error: 'sprite' does not name a type f:/homebrew/buttonTest/source/template.cpp: In member function 'void button::genImage()': f:/homebrew/buttonTest/source/template.cpp:88: error: 'buttonImg' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:91: error: 'buttonImg' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:94: error: 'buttonImg' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:97: error: 'buttonImg' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:100: error: 'buttonImg' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:104: error: 'buttonSpr' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:104: error: 'buttonImg' was not declared in this scope f:/homebrew/buttonTest/source/template.cpp:105: error: 'buttonSpr' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp:106: error: 'buttonSpr' is not a member of 'button' f:/homebrew/buttonTest/source/template.cpp: In member function 'void button::buttonDraw()': f:/homebrew/buttonTest/source/template.cpp:109: error: 'buttonSpr' is not a member of 'button'
Re: objects help December 28, 2009 01:39PM | Admin Registered: 15 years ago Posts: 5,132 |
Re: objects help December 28, 2009 07:47PM | Registered: 15 years ago Posts: 444 |
LayerManager manager(1);Here are the errors:
:/homebrew/buttonTest/source/template.cpp:82: error: expected identifier before numeric constant f:/homebrew/buttonTest/source/template.cpp:82: error: expected ',' or '...' before numeric constant f:/homebrew/buttonTest/source/template.cpp: In member function 'void buttonObj::genButton()': f:/homebrew/buttonTest/source/template.cpp:110: error: '((buttonObj*)this)->buttonObj::manager' does not have class type f:/homebrew/buttonTest/source/template.cpp: In member function 'void buttonObj::buttonDraw()': f:/homebrew/buttonTest/source/template.cpp:113: error: '((buttonObj*)this)->buttonObj::manager' does not have class typeI'm pretty sure that the last 2 errors are because of the LayerManager messing up.
Re: objects help December 28, 2009 08:26PM | Admin Registered: 15 years ago Posts: 5,132 |
Re: objects help December 28, 2009 09:39PM | Registered: 15 years ago Posts: 444 |
class buttonObj{ public: void setMessage(char* m){ strcpy(msg,m); } char* getMessage(){ return msg; } void setLocation(int X,int Y){ x=X; y=Y; } int getX(){ return x; } int getY(){ return y; } void setDim(int w,int h){ width = w; height = h; } int getWidth(){ return width; } int getHeight(){ return height; } void setColor(BUTTON_COLOR c){ color = c; } BUTTON_COLOR getColor(){ return color; } void genButton(); void buttonDraw(); private: int x,y; int width; int height; char* msg; BUTTON_COLOR color; Image buttonImg; Sprite buttonSpr; LayerManager manager(1); };
Re: objects help December 28, 2009 09:52PM | Admin Registered: 15 years ago Posts: 5,132 |
Re: objects help December 28, 2009 11:07PM | Registered: 15 years ago Posts: 444 |