java engine_java使用OGEngine开发2048
最近有一款2048的游戲非?;?#xff0c;本文將來介紹一下使用OGEngine游戲引擎開發游戲2048。
OGEngine引擎是開源的,我們很容易找到,搭建起來也很方便,我們只需在Android工程下添加OGEngine的jar包或者直接引用源碼就可以了。
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有所幫助。
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的java engine_java使用OGEngine开发2048的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java双大括号_什么是Java中的双B
- 下一篇: bminfowindow是什么_三步实现