java使用OGEngine開發2048_java

來源:互聯網
上載者:User

最近有一款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有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.