There is a 2048 game that is very popular recently. This article will introduce the use of OGEngine game engine to develop the game 2048.
The OGEngine engine is open source. It is easy to find and easy to build. We only need to add the OGEngine jar package under the Android project or directly quote the source code.
Source code download: http://www.ogengine.com/download/resources.jsp
private void initView() { // Game background AnimatedSprite game_bg = new AnimatedSprite(0, 0, Res.GAME_BG, getVertexBufferObjectManager()); this.attachChild(game_bg); // Middle game main part mGameGroup = new GameGroup(this); // Set the center position of the Group to the center point of the lens 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); // Best score background bestScoreBg = new AnimatedSprite(0, 20, Res.GAME_SCORE_BG_BEST, getVertexBufferObjectManager()); // Set the x coordinate position on the right side of bestScoreBg to the right side of the lens minus 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()); // Set the midpoint of the X coordinate of tBestScore to the midpoint of the X coordinate of bestScoreBg tBestScore.setCentrePositionX(bestScoreBg.getCentreX()); this .attachChild(tBestScore); // Current score background currScoreBg = new AnimatedSprite(0, bestScoreBg.getY(), Res.GAME_SCORE_BG_NOW, getVertexBufferObjectManager()); // Set the right X coordinate point of currScoreBg to the position of the X coordinate on the left side of bestScoreBg minus 20 currScoreBg.setRightPositionX(bestScoreBg.getLeftX() - 20); this.attachChild(currScoreBg);..... }
The above is the entire content of this article. I hope you will like it and it will help you master Java proficiently.