class Tile : public ImageComponent
{
public:
Tile(std::string id, const Image& image)
: ImageComponent(id)
{
setImage(image);
}
};
class Tab : public Component
{
Tab()
{
int size;
// process size
for (int a = 0; a < size; a++)
{
nodes.add(&getDefaultTile());
addAndMakeVisible(*nodes[a]);
}
}
static Tile& getDefaultTile()
{
static Tile defaultTile("-1", getImageFromFile("Asset/defaultNodeImage.png"));
///////// getImageFromFile() simply loads image from file and return it.
return defaultTile;
}
OwnedArray<Tile> nodes;
}
this code doesnt render anything. but when i make this to add node
for (int a = 0; a < size; a++)
{
nodes.add(new Tile("-1", getImageFromFile("Asset/defaultNodeImage.png"));
addAndMakeVisible(*nodes[a]);
}
it works but i really need to make the first snippet work so i wont need to allocate bunch of Tile that has the same state.
any help is appreciated thanks.
