手机网游制造之网络通信篇
2009-10-11 00:00:00 来源:WEB开发网第四步:在按键处理中添加发送指令
在已有的按键处理代码基础上,编写发送指令的代码。其中关键码如下所示(完整代码下载地址:http://www.shudoo.com/bzsoft):
playerDire = DIRE_UP; //改变方向
if(playerY - BOX_TILE_HEIGHT > 22){//边界检测
new HttpThread(generateMoveData(DIRE_UP),this); //发送指令
}
break;
case DOWN:
playerDire = DIRE_DOWN; //改变方向
if(playerY + SPRITE_HEIGHT + BOX_TILE_HEIGHT < 210){//边界检测
new HttpThread(generateMoveData(DIRE_DOWN),this); //发送指令
}
break;
case LEFT:
playerDire = DIRE_LEFT; //改变方向
if(playerX - TILE_WIDTH > 0){//边界检测
new HttpThread(generateMoveData(DIRE_LEFT),this); //发送指令
}
break;
case RIGHT:
playerDire = DIRE_RIGHT; //改变方向
if(playerX + TILE_WIDTH + SPRITE_WIDTH < width){//边界检测
new HttpThread(generateMoveData(DIRE_RIGHT),this); //发送指令
更多精彩
赞助商链接