int OnButton(int id)
{
//do something...
return 0;
}
//ButtonAdd("filename", x-cor, y-cor, function, id#)
ButtonAdd("Images/Button", 0, 0, OnButton, 0);
int OnButton(int id)
{
if( id == 1 )
//do something...
if( id == 2 )
//do something...
if( id == 3 )
//do something
return 0;
}
ButtonAdd("Images/Button", 0, 0, OnButton, 1);
ButtonAdd("Images/Button", 50, 0, OnButton, 2);
ButtonAdd("Images/Button", 100, 0, OnButton 3);
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);
}
string s = "ola";
TextAdd(x,y, (char *)s.c_str() );
void OnTimer()
{
// Get the circles moving:
for (int i=0; i<n.balls; i++)
{
xcur=ViewGetx(Balls[i].ViewHandle);//get the current x coord. of the n.0
ycur=ViewGety(Balls[i].ViewHandle);//get the current y coord. of the n.0
for (int j=i+1; j<MAX_BALLS; j++)//verify the collision for all the balls
{
x2cur=ViewGetx(Balls[j].ViewHandle);//get the current x coord. of the ball n.1
y2cur=ViewGety(Balls[j].ViewHandle);//get the current y coord. of the ball n.1
//then you have now the position of 2 balls, and you can calculate the distance, the for loop will think to calculate all the combinations
d=sqrtf((x2cur-xcur)*(x2cur-xcur)+(y2cur-ycur)*(y2cur-ycur));//pitagora's theorem calculates the distance between the two balls
if (d>BallWidth || d==0)//control if the distance between the two balls is 0 or less (superimposed the ball),then the collision has occurred
//What do you want to do after that the collision has occurred
}
int createNewFile(std::string fileurl)
{
int temp = FileCreate(toCString(fileurl));
return FileOpen(toCString(fileurl));;
}
int getFileHandle(std::string fileurl)
{
return FileOpen(toCString(fileurl));
}
std::string readFromFile(int filehandle, int numOfBytes, int startByte)
{
char* buffer = new char[numOfBytes+1];
int fileLength = FileLength(filehandle);
if( (startByte + numOfBytes) <= fileLength ) //If we try to read out of bounds
{
FileSeek(fileHandle,startByte); //Set 'cursor' for reading bytes
FileRead(fileHandle,buffer,numOfBytes);
buffer[numOfBytes] = '\0'; //Null terminate the character arra
std::string s(buffer);
delete[] buffer;
buffer = 0;
return s;
}
else
{
delete[] buffer;
buffer = 0;
return "";
}
}
void writeToFile(int filehandle, std::string text)
{
char* buffer = new char[text.length()];
for(int i = 0; i < (int)text.length(); i++)
*(buffer+i) = text[i];
FileWrite(filehandle, buffer, (int)text.length());
delete [] buffer;
buffer = 0;
return;
}
bool openFile(std::string fileurl)
{
int temp = FileOpen(toCString(fileurl));
return temp != 0 ? true : false; //returns true if temp is not 0
//meaning a file did exist
}
void closeFile(int filehandle)
{
FileClose(filehandle);
return;
}
char* toCString(std::string s)
{
char* temp = new char[s.length()];
for(int i = 0; i < (int)s.size(); i++)
temp[i] = s[i];
temp[s.length()] = '\0';
return temp;
}