WEB开发网
开发学院手机开发iPhone 开发 iPhone方块游戏拖动手势源码共享 阅读

iPhone方块游戏拖动手势源码共享

 2010-08-22 00:49:00 来源:WEB开发网   
核心提示:GameStatePlay::TouchesEnded(){//主区域检测旋转,模拟按了一下旋转键if(g_first_touch[1]<=368 && g_first_touch[1]>=46){g_end_touch[0]=mApp->touch_x;g_end_touch[1]=mApp->
GameStatePlay::TouchesEnded(){//主区域检测旋转,模拟按了一下旋转键if(g_first_touch[1]<=368 && g_first_touch[1]>=46){g_end_touch[0]=mApp->touch_x;g_end_touch[1]=mApp->touch_y; //printf("TE:%f %f ", g_end_touch[0], g_end_touch[1]); float dx = fabs(g_end_touch[0]-g_first_touch[0]);float dy = fabs(g_end_touch[1]-g_first_touch[1]); if(dx<=15 && dy<=15){//printf("PUT A TURN KEY ");g_key[ELSKEY_TURN][0]=KEY_PRESSED;g_key[ELSKEY_TURN][1]=0;}return;} //松开屏幕清理... for(int i=0;i<16;i++){if(g_key[i][0]==0 && g_key[i][1]==0)continue; //如果键被TestKey检测到了,松手时清空这个键位if(g_key[i][1]!=0){g_key[i][0]=KEY_UP;g_key[i][1]=0;}//如果在TestKey之前就松手了,置一个键被点击的状态else{g_key[i][0]=KEY_PRESSED;g_key[i][1]=0;}}} //游戏主循环调用Update,不停的检测按键事件并处理...void GameStatePlay::Update(float dt){//保存if(TestKey(ELSKEY_HOLD))SaveBlk(0, false); //旋转if(TestKey(ELSKEY_TURN))MoveBlk(TURN, 0, false); //直下if(TestKey(ELSKEY_DROP)){while(MoveBlk(DDOWN, 0, false)!=REACH_BOTTOM);NextBlk(0, false);} //右移if (TestKey(ELSKEY_RIGHT))MoveBlk(RIGHT, 0, false); //左移if(TestKey(ELSKEY_LEFT))MoveBlk(LEFT, 0, false); //下移if (TestKey(ELSKEY_DOWN)) MoveBlk(DOWN, 0, false);

上一页  1 2 3 

Tags:iPhone 方块 游戏

编辑录入:coldstar [复制链接] [打 印]
赞助商链接