Everything works great and as expected,
And since I had an array filled with anim classes anyway there where no reason to use
the block scope and temporary instantiation of the anim class.
const uint32_t MAX_ANIM_ARRAY =20;
class Scene {
public:
std::vector<DrawableCLASS*> DrawVec;
std::array<AnimCLASS, MAX_ANIM_ARRAY> DrawAnimArray;
void Define(int SN);
void Setup() {
for (auto& item : DrawVec)
item->Init();
}
void Render(sf::RenderWindow &window) {
for (auto& item : DrawVec)
item->Render(window);
}
}
Scene::Define(int sn) {
uint32_t index=0;
if(sn==Scene_Intro) {
// - layer 0
DrawAnimArray[index].Define("Background", 0, true, true, 1,"textures/Art01", 0,0, 1.0f,1.0f,0);
DrawVec.push_back(&DrawAnimArray[index]);
index++;
// - layer 1
DrawAnimArray[index].Define("Forground", 0, true, true, 1,"textures/Art02", 0,0, 1.0f,1.0f,0);
DrawVec.push_back(&DrawAnimArray[index]);
index++;
// - layer 2
DrawAnimArray[index].Define("Actor sprite", 0, true, true, 1,"textures/Actor02", 0,0, 1.0f,1.0f,0);
DrawAnimArray[index].SetClickPoint(true, true, "Dynamic", "ActorName", "ACTOR_YES" ,0 , "Cursor_Green", 748,380, 48, 72);
DrawVec.push_back(&DrawAnimArray[index]);
index++;
if(index> MAX_ANIM_ARRAY) throw std::Kitchen::Sink;
}
};
I played with the refrence wrapper and got it to work by going though an extra function to un-wrap before it could be rendered, so if I really wanted to get rid of std::vector<DrawableCLASS*> DrawVec; I could use that.