int ViewAdd(char *filename, int x, int y, int (*callback)(int id, int event, int x, int y), int id);


Add a View with an Image and a Touch callback


Return Value


Returns an int handle to the view.





The file must be located in the folder where the exe is running. This is typically inside your Visual C++ project in your /Debug folder. A filename "Ball.png" will be loaded from Debug/Ball.png. If the filename specified is "Images/Ball.png" the file will be loaded from Debug/Images/Ball.png. If a path is included in the filename, it is a relative path from the Debug folder (where the exe is running from). Use forward slashes / as needed (not backslash) and never start a filename path with a slash.


The path to the file named in this parameter must be in the Assets folder where your application resides.  (Typically, your project's Debug or Release folder.  For example, if your project is in C:\DragonFireSDK\, your Assets folder will be C:\DragonFireSDK\Debug\Assets or C:\DragonFireSDK\Release\Assets.)


NOTE: The file system used by iOS is case sensitive, so be sure to match the case of the file name in your code to that of the file on your computer.



x coordinate.



y coordinate.



Specifies a function that will be called when the image in this view is touched.


int OnBall(int id, int event, int x, int y)     //event: 1=down, 2=move, 3=up


       if (event == 3)

       {   // touch up (touched and released)

               // something


       return 0;




Touch id to be sent to callback.




The ViewAdd() function makes an image visible. This function internally calls ImageAdd() for you and assigns the image specified by the filename to the view. It also internally calls TouchAdd() to setup a touch area the size of the image and the callback you specify will be called when the View/Image/Touch is touched. The callback must be defined with the parameters listed.




Available in DragonFireSDK 1.0 and later.




This example adds a view with an image of a card to the screen and sets a callback.


#include "DragonFireSDK.h"


int OnTouch(int id,int event,int x, int y)


       printf("You touched the card!\n");




void AppMain()





void AppExit()





void OnTimer()