All seems fine. I can narrow issues to a exact line of code
Game Object Class
----------Game Object H----------------
#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H
#include "cocos2d.h"
#include <string>
class GameObject
{
public:
GameObject(std::string filename, std::string tag, std::string type, cocos2d::Vec2 position, cocos2d::Vec2 anchor, int serial);
~GameObject();
cocos2d::Sprite* getSprite();
private:
int m_Serial;
std::string m_Tag;
std::string m_Type;
cocos2d::Vec2 m_Position;
cocos2d::Vec2 m_Target;
cocos2d::Sprite* m_Sprite;
};
#endif // DEFINE - GAMEOBJECT_H
-----Game Object CPP--------------------------------------------------------------
#include "GameObject.h"
GameObject::GameObject(std::string filename, std::string tag, std::string type, cocos2d::Vec2 position, cocos2d::Vec2 anchor, int serial) {
m_Sprite = cocos2d::Sprite::create(filename);
m_Tag = tag;
m_Type = type;
m_Sprite->setPosition(position);
m_Sprite->setAnchorPoint(anchor);
m_Serial = serial;
m_Target = cocos2d::Vec2(0, 0);
}
GameObject::~GameObject(){
}
cocos2d::Sprite * GameObject::getSprite(){
return m_Sprite;
}
--------------------------------GUI H------------------------------------------------------
I call it in GUI Class
#ifndef GUILAYER_H
#define GUILAYER_H
#include "cocos2d.h"
#include "GameObject.h"
#include <string>
class GuiLayer
{
public:
GuiLayer(cocos2d::Size windowSize);
~GuiLayer();
private:
cocos2d::Size m_WindowSize;
GameObject* m_Bottom;
};
#endif // DEFINE - GUILAYER_H
------------------------------GUI CPP----------------------------------------
This is where it crashed on android but works fine on win32
GuiLayer::GuiLayer(cocos2d::Size windowSize) {
m_WindowSize = windowSize;
m_Bottom = new GameObject("HUD/UI/bottom.png", "Bottom", "UI", cocos2d::Vec2(0, 0), //HERE cocos2d::Vec2(0, 0), 0);
}
Test Scene CPP
void TestScene::drawHUD(){
m_HUD = new GuiLayer(m_VisableSize);
GameObject* m_Bottom = new GameObject("hud/ui/bottom.png", "Bottom", "UI", cocos2d::Vec2(0, 0), cocos2d::Vec2(0, 0), 0);//NO PROBLEM HERE
m_Bottom->getSprite()->setPosition(cocos2d::Vec2(500,0));
m_HUDLayer->addChild(m_Bottom->getSprite());
for (auto graphic : m_HUD->returnGraphics()) { // I THINK ISSUE WITH THIS
CCLOG("ONE");
//m_HUDLayer->addChild(graphic->getSprite(), 0);
}
}
If i remove that line to construct new Game Object all works fine. it works fine with the game object on Win32. it builds fine and APP opens for a couple seconds and closes. On windows i can view sprite and all is fine
i tried cleaning project and swapping things around so as use init() instead, cant spot issue
It has to be something I never seen before because this all looks perfect to me.