Here's another example coming your way, flipping pages!
The idea behind flipping pages is you have multiple groups of elements, say, a menu and a choice in that menu to choose a level. To use this, we need at least two containers. A container is like a big package. You can put all of your buttons and images within a container. To flip pages, you turn one container's contents off (temporarily) and turn another's on, creating an illusion that you are flipping pages. Here's the code
int container1;
int container2;
int OnButton(int id)
{
if( id == 1 )
{
ContainerSetVisible(container1,0);
ContainerSetVisible(container2,1);
}
else if( id == 2 )
{
ContainerSetVisible(container1,1);
ContainerSetVisible(container2,0);
}
return 0;
}
AppMain()
{
//Create your containers first
container1 = ContainerAdd(0,0,0);
container2 = ContainerAdd(0,0,0);
//Add images or buttons to your container
ViewAdd = (container1, 0,0, "Image.png");
ButtonAdd = (container1, 0,0, "Button", OnButton, 1);
ViewAdd = (container2, 0,0, "Image_two.png");
ButtonAdd = (container2, 0,0, "Button", OnButton, 2);
//Set visibility flags for each container
ContainerSetVisible(container1,1);
ContainerSetVisible(container2,0);
}
The code above creates two pages and one button to swap between them.