I got error: “Unhandled exception at 0x107FB141 (libcocos2d.dll) in Ball.exe: 0xC0000005: Access violation reading location 0x00000014.”
I wana create a HUD class to add Controls:
.H file:
#include "cocos2d.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
class HUD_Layer :public cocos2d::LayerColor
{
public:
HUD_Layer();
~HUD_Layer();
void initOptions();
ui::Button *btnForward;
static HUD_Layer* createLayer();
virtual void draw(cocos2d::Renderer * renderer, const cocos2d::Mat4 & transform, bool transformUpdated);
};
#endif // __HUD_LAYER_H__
.cpp source:
#include “HUD_Layer.h”
USING_NS_CC;
using namespace std;
HUD_Layer::HUD_Layer()
{
}
HUD_Layer::~HUD_Layer()
{
}
HUD_Layer* HUD_Layer::createLayer()
{
HUD_Layer *a = new HUD_Layer();
a->create();
//a->setColor(cocos2d::Color3B(0, 0, 0));
a->setContentSize(Size(cocos2d::Director::getInstance()->getVisibleSize().width, cocos2d::Director::getInstance()->getVisibleSize().height));
a->setAnchorPoint(cocos2d::Vec2(0, 0));
a->initOptions();
return a;
}
void HUD_Layer::initOptions()
{
Size visibleSize = Director::getInstance()->getVisibleSize();
btnForward = ui::Button::create();
btnForward >setPosition(Vec2(visibleSize.width / 2, 30));
addChild(btnForward );
}
void HUD_Layer::draw(cocos2d::Renderer * renderer, const cocos2d::Mat4 & transform,bool transformUpdated) {}
I declared a HUD_Layer in HelloWorld.:init():
HUD_Layer *HUD = HUD_Layer::createLayer();
this->addChild(HUD);
And I got the error: “Unhandled exception at 0x107FB141 (libcocos2d.dll) in Ball.exe: 0xC0000005: Access violation reading location 0x00000014.” and It show cause from GL::useProgram(_program) at CCGLProgram
Any help me! apriciate so much!