java應用OGEngine開辟2048。本站提示廣大學習愛好者:(java應用OGEngine開辟2048)文章只能為提供參考,不一定能成為您想要的結果。以下是java應用OGEngine開辟2048正文
比來有一款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有所贊助。