Hi,
Today I created my own class called “MessageBox” inside my C++ cocos2d-x project.
Here is my MessageBox.h
#ifndef __MESSAGEBOX_H__
#define __MESSAGEBOX_H__
#include "cocos2d.h"
using namespace cocos2d;
class MessageBox : public Node
{
public:
static MessageBox* createWithResources(Texture2D *textureBackground, Texture2D *textureButton, std::string title, std::string text, std::string yes, std::string no);
bool init(Texture2D *textureBackground, Texture2D *textureButton, std::string title, std::string text, std::string yes, std::string no);
};
#endif
And here’s my MessageBox.cpp
#include "MessageBox.h"
using namespace cocos2d;
MessageBox* MessageBox::createWithResources(Texture2D *textureBackground, Texture2D *textureButton, std::string title, std::string text, std::string yes, std::string no)
{
MessageBox *e = new (std::nothrow) MessageBox();
if (e)
{
if (e->init(textureBackground, textureButton, title, text, yes, no)) {
e->autorelease();
return e;
}
}
CC_SAFE_DELETE(e);
return nullptr;
}
bool MessageBox::init(Texture2D *textureBackground, Texture2D *textureButton, std::string title, std::string text, std::string yes, std::string no)
{
if (!Node::init())
{
return false;
}
return true;
}
When I compile I get these errors. Particularly the second error looks weird to me. Because declaration and usage is exactly the same. But I still get the error.
Can you help me please? Thanks in advance.