Java:在二维动画中使用基于图像的路径 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-15
)) { case BuildingManager.STATE_EXIT: atExit = true; break; case BuildingManager.STATE_START: case BuildingManager.STATE_INTERSECTION: // process any hints if (manager.stateAt(x - 1, y) == BuildingManager.STATE_HINT) setDirection(Person.DIR_WEST); else if (manager.stateAt (x + 1, y) == BuildingManager.STATE_HINT) setDirection(Person.DIR_EAST); else if (manager.stateAt(x, y + 1) == BuildingManager.STATE_HINT) setDirection (Person.DIR_SOUTH); else if (manager.stateAt(x, y - 1) == BuildingManager.STATE_HINT) setDirection(Person.DIR_NORTH); // no hints, select a direction if (getDirection() == DIR_NONE) { if (manager.stateAt(x - 1, y) != BuildingManager.STATE_NONE) setDirection (Person.DIR_WEST); else if (manager.stateAt(x + 1, y) != BuildingManager.STATE_NONE) setDirection(Person.DIR_EAST); else if (manager.stateAt(x, y + 1) != BuildingManager.STATE_NONE) setDirection (Person.DIR_SOUTH); else if (manager.stateAt(x, y - 1) != BuildingManager.STATE_NONE) setDirection(Person.DIR_NORTH); } case BuildingManager.STATE_HALLWAY: case BuildingManager.STATE_HINT: // effect motion in selected direction int tempX = x; int tempY = y; switch (getDirection()) { case DIR_EAST: x += 1; break; case DIR_WEST: x -= 1; break; case DIR_NORTH: y -= 1; break; case DIR_SOUTH: y += 1; break; } int check = manager.stateAt(x, y); if (check == manager.STATE_UNKNOWN || check == manager.STATE_NONE) { // went off the path, backup x = tempX; y = tempY; if (getDirection() == DIR_EAST || getDirection() == DIR_WEST) { if (manager.stateAt(x, y + 1) != BuildingManager.STATE_NONE && manager.stateAt(x, y + 1) != BuildingManager.STATE_UNKNOWN) { setDirection(Person.DIR_SOUTH); y += 1; } else { // Only direction not checked is north setDirection(Person.DIR_NORTH); y -= 1; } } else { if (manager.stateAt(x + 1, y) != BuildingM |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Java:在二维动画中使用基于图像的路径 - 编程入门网的所有评论