java使用OGEngine开发2048
时间:2020-11-13 08:22:15|栏目:JAVA代码|点击: 次
最近有一款2048的游戏非常火,本文将来介绍一下使用OGEngine游戏引擎开发游戏2048。
OGEngine引擎是开源的,我们很容易找到,搭建起来也很方便,我们只需在Android工程下添加OGEngine的jar包或者直接引用源码就可以了。
源码下载:http://www.ogengine.com/download/resources.jsp
private void initView() {
// 游戏背景
AnimatedSprite game_bg = new AnimatedSprite(0, 0, Res.GAME_BG,
getVertexBufferObjectManager());
this.attachChild(game_bg);
// 中间游戏主体部分
mGameGroup = new GameGroup(this);
// 设置改Group的中心位置在镜头的中心点上
mGameGroup.setCentrePosition(this.getCameraCenterX(),
this.getCameraCenterY());
this.attachChild(mGameGroup);
// 2048 LOGO
AnimatedSprite game_logo = new AnimatedSprite(20, 20, Res.GAME_LOGO,
getVertexBufferObjectManager());
this.attachChild(game_logo);
// 最佳得分背景
bestScoreBg = new AnimatedSprite(0, 20, Res.GAME_SCORE_BG_BEST,
getVertexBufferObjectManager());
// 设置bestScoreBg右边x坐标的位置在镜头的右边减20的位置
bestScoreBg.setRightPositionX(this.getCameraRightX() - 20);
this.attachChild(bestScoreBg);
tBestScore = new Text(0, bestScoreBg.getY() + 50,
FontRes.getFont(ConstantUtil.FONT_SCORE_NUM),
SharedUtil.getBestScore(getActivity()) + "", 4,
getVertexBufferObjectManager());
// 设置 tBestScore 的X坐标上的中点在bestScoreBg的X坐标中点上
tBestScore.setCentrePositionX(bestScoreBg.getCentreX());
this.attachChild(tBestScore);
// 当前得分背景
currScoreBg = new AnimatedSprite(0, bestScoreBg.getY(),
Res.GAME_SCORE_BG_NOW, getVertexBufferObjectManager());
// 设置currScoreBg的右边X坐标点在bestScoreBg左边的X坐标减20的位置上
currScoreBg.setRightPositionX(bestScoreBg.getLeftX() - 20);
this.attachChild(currScoreBg);
.....
}
以上所述就是本文的全部内容了,希望大家能够喜欢,能够对大家熟练掌握java有所帮助。
上一篇:IntelliJ IDEA 安装 Grep Console插件 自定义控制台输出多颜色格式功能
栏 目:JAVA代码
下一篇:Spring AOP定义Before增加实战案例详解
本文标题:java使用OGEngine开发2048
本文地址:http://www.codeinn.net/misctech/21941.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




