java使用OGEngine开发2048
作者:hebedich 时间:2023-07-23 06:07:43
最近有一款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有所帮助。
标签:java,OGEngine,开发2048
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Spring Boot整合Web项目常用功能详解
2023-06-04 17:14:21
SpringBoot日志框架之Log4j2快速入门与参数详解
2023-11-15 21:17:59
![](https://img.aspxhome.com/file/2023/3/61653_0s.webp)
Android实现在一个activity中添加多个listview的方法
2023-10-13 14:41:22
java实现文件重命名的方法
2022-11-06 05:42:25
Android编程之防止反编译的实现方法
2021-10-31 04:23:35
Android 设置Edittext获取焦点并弹出软键盘
2022-02-28 12:02:02
关于ObjectUtils.isEmpty() 和 null 的区别
2022-05-07 17:10:56
![](https://img.aspxhome.com/file/2023/2/66672_0s.jpg)
C#实现程序等待延迟执行的方法
2023-07-16 06:32:36
C++如何调用已经写好的C接口
2021-10-16 10:16:14
![](https://img.aspxhome.com/file/2023/0/129550_0s.png)
Java Lambda表达式与匿名内部类的联系和区别实例分析
2022-01-05 21:10:22
logback使用filter过滤日志操作
2022-07-11 03:20:27
![](https://img.aspxhome.com/file/2023/5/63765_0s.jpg)
Java接口默认方法带来的问题分析【二义性问题】
2023-11-27 20:32:55
![](https://img.aspxhome.com/file/2023/7/60117_0s.png)
Java如何构造DSL方法重构
2021-10-10 02:04:09
使用Spring Boot进行单元测试详情
2023-11-10 08:01:53
详谈jvm--Java中init和clinit的区别
2022-01-10 10:35:22
Kotlin的::符号怎么用
2022-07-13 22:59:37
spring AOP的Around增强实现方法分析
2021-10-03 06:22:39
Android中的LeakCanary的原理详解
2021-06-18 09:16:40
![](https://img.aspxhome.com/file/2023/0/100620_0s.png)
详细总结Java堆栈内存、堆外内存、零拷贝浅析与代码实现
2023-11-21 01:52:29
![](https://img.aspxhome.com/file/2023/5/59325_0s.png)
Android使用phonegap从相册里面获取照片(代码分享)
2023-07-24 18:53:03