I am just now trying to show sprite on stage using CCSprite.
The character class is a class which has succeeded to the CCSprite.
I wrote the code as following:
bool HellowWorld::init() method:
bool HelloWorld::init()
{
int Indexes[9] = {5,11,15,16,17,19,20,21,25};
int x;
int y;
CCArray *filename = new CCArray();
filename->addObject(new CCString("1-1.png"));
filename->addObject(new CCString("2-1.png"));
filename->addObject(new CCString("1-2.png"));
filename->addObject(new CCString("2-3.png"));
filename->addObject(new CCString("2-3.png"));
filename->addObject(new CCString("1-2.png"));
filename->addObject(new CCString("2-3.png"));
filename->addObject(new CCString("1-1.png"));
filename->addObject(new CCString("1-1.png"));
for(int i=0;i<9;i++){
const char *MyImage = ((CCString*)filename->objectAtIndex(i))->getCString();
characters *chara = (characters*)CCSprite::create(MyImage);
x = Indexes[i]%HORIZONTAL_AXIS;
y = Indexes[i]/HORIZONTAL_AXIS;
CCPoint point = ccp(MARGIN_WIDTH + PIPE_WIDTH * x,MARGIN_HEIGHT + PIPE_HEIGHT * y);
chara->setPosition(point);
this->addChild(chara,1);
}
But, I am getting the following error message:
libc++abi.dylib: terminating with uncaught exception of type std::length_error: basic_string::_S_create
How should I solve this issue?