IntroductionHello. Zacho here. After receiving wonderful and insightful help from the members of this forum, I have been inspired to help others as they have helped me. This thread will be where I will update tidbits of code to accomplish tasks using DragonFireSDK once I have learned the tricks. Most importantly... this thread will be a
COMMUNITY THREADin that everyone can contribute code and examples to share with each other. If you have a good example that you found yourself appraising please post it here so our knowledge of DragonFireSDK can continue to grow. Please post code using [ code ] [/ code ] tags.
Topics in threadTo create a button, you must have two things; a function that is called when this button is pressed and two separate images for this button. The two images must have the same name and end with a 1 and a 2.
Button1.png - Button2.png
The function can look like something below (feel free to copy the code).
[/list]
int OnButton(int id)
{
//do something...
return 0;
}
//ButtonAdd("filename", x-cor, y-cor, function, id#)
ButtonAdd("Images/Button", 0, 0, OnButton, 0);
The paramater "id" can be thought of as a case. For example, if three copies of this button were made right next to each other, so that three buttons sat side-by-side onscreen, the id would do something separate for each button. If the far-leftmost button was hit, the id called might be 1. The middle button's id might be 2 and the far-rightmost button's id might be 3.
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);