Touch event code

smilytics

Touch event code

sample


Code

#include <EntryPoint.h>

static void UpdateFunc(void);

wzTexture g_gazou1;        //image
wzVector2 g_ringPos[3];    //cursor pos

int Initialize()
{   //!App initialize Process
    wzInitCreateWizapply("smatcha sample",320,480,0);
    wzSetClearColor(0.1f,0.1f,0.1f);
    wzSetSpriteScSize(320, 480);

    //file path to correspond to the various platforms that give shDCP.
    //For Windows "./contents" folder into the image.
    if(wzCreateTextureFromPNG(&g_gazou1, wzDCP("mover.png"))) {
        printf("Failed to load the image.\n");
        return 1;
    }

    wzSetUpdateThread(60,UpdateFunc);

    return 0;
}

int Terminate()
{   //!App exit process
    wzDeleteTexture(&g_gazou1);
    wzExitSherry();
    return 0;
}

void DrawLoop(void)
{   //!Draw
    int i;
    wzVector2 texcoord[3] = {{0.0f,0.5f},{0.5f,0.0f},{0.5f,0.5f}};

    // Screen Clear
    wzClear();

    // Desable depth
    wzSetDepthTest(SH_FALSE);

    // Draw
    for(i = 0; i < 3; i++) {
        wzSetSpriteColor(1.0f, 1.0f, 1.0f, 1.0f);
        wzSetSpritePosition(g_ringPos[i].x,g_ringPos[i].y,0.0f);
        wzSetSpriteSize(64,64);
        wzSetSpriteTexCoord(texcoord[i].x, texcoord[i].y, 0.5f, 0.5f);
        wzSetSpriteTexture(&g_gazou);
        wzSpriteDraw();
    }
}

void UpdateFunc(void)
{   //!Update
    int i;

    int isTouch[3] = {0};
    wzVector2 mousePos[3];

    // Windows, for Mac, PC, enter only one of the mouse cursor.
    for(i = 0; i < 3; i++)
        isTouch[i] = wzGetCursorSrPos(i, &mousePos[i].x, &mousePos[i].y);

    for(i = 0; i < 3; i++) {
        g_ringPos[i].x = g_ringPos[i].y = (-256.0f);    //Out screen
        if(isTouch[i]) {
            g_ringPos[i].x = mousePos[i].x;
            g_ringPos[i].y = mousePos[i].y;
        }
    }
}

Contents

mover.png

sample


MongoDB Logo MongoDB