Chunker终极教程:3步完成Minecraft跨平台存档转换
2025/12/26 7:15:38
在游戏开发中,角色和敌人的移动以及角色的动画表现是非常重要的部分。本文将详细介绍如何实现角色的移动、动画,以及如何加载和移动敌人。
角色的移动可以根据不同的操作进行左右移动或站立。以下代码展示了如何根据玩家的动作来移动角色:
switch(playeraction){ case PLAYER_MOVE_RIGHT: playercurrentlocation += PLAYER_RUN_SPEED; Matrix.translateM(mTMatrix, 0, 0, playercurrentlocation, 0); Matrix.multiplyMM(mMVPMatrix, 0, mTMatrix, 0, mMVPMatrix, 0); character.draw(mMVPMatrix); break; case PLAYER_MOVE_LEFT: playercurrentlocation -= PLAYER_RUN_SPEED; Matrix.translateM(mTMatrix, 0, 0, playercurrentlocation, 0); Matrix.multiplyMM(mMVPMatrix, 0, mTMatrix, 0, mMVPMatrix, 0); character.draw(mMVPMatrix); break; case PLAYER_STAND: PLAYER_RUN_SPEED = .15f; totalGameLoops = 0; bre