• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Codejie's C++ Space

            Using C++

            LIBGDX: Star.apk


                90分鐘寫(xiě)好的一個(gè)基于libgdx的android應(yīng)用,有興趣的下載看看,也算這段時(shí)間研究libgdx的總結(jié)吧。。。版本需要2.1及其以上版本,由于cppblog.com附件后綴上傳限制,下載Star-Android.apk.7z后,請(qǐng)去掉.7z后綴,再安裝,程序名稱(chēng)為--star。別忘記android手機(jī)的觸屏功能哦。。。

                Mac下不知道怎么截屏,明天再上圖吧~


            Source Code:

              1 /**
              2  * file:   StarGame.java
              3  * author: codejie (codejie@gmail.com)
              4  * date:   Jun 2, 2011 11:32:00 PM
              5  */
              6 package com.jie.android.gdx.star;
              7 
              8 import com.badlogic.gdx.Game;
              9 import com.badlogic.gdx.Gdx;
             10 import com.badlogic.gdx.InputProcessor;
             11 import com.badlogic.gdx.graphics.GL10;
             12 import com.badlogic.gdx.graphics.Texture;
             13 import com.badlogic.gdx.math.MathUtils;
             14 import com.badlogic.gdx.scenes.scene2d.Action;
             15 import com.badlogic.gdx.scenes.scene2d.OnActionCompleted;
             16 import com.badlogic.gdx.scenes.scene2d.Stage;
             17 import com.badlogic.gdx.scenes.scene2d.actions.FadeTo;
             18 import com.badlogic.gdx.scenes.scene2d.actions.MoveTo;
             19 import com.badlogic.gdx.scenes.scene2d.actions.Parallel;
             20 import com.badlogic.gdx.scenes.scene2d.actions.RotateTo;
             21 import com.badlogic.gdx.scenes.scene2d.actions.ScaleTo;
             22 import com.badlogic.gdx.scenes.scene2d.actors.Image;
             23 
             24 public class StarGame extends Game implements InputProcessor {
             25 
             26     /* (non-Javadoc)
             27      * @see com.badlogic.gdx.ApplicationListener#create()
             28      */
             29     
             30     private Stage stage = null;
             31     private Texture ballTexture = null;
             32     private Texture starTexture = null;
             33     
             34     @Override
             35     public void create() {
             36         // TODO Auto-generated method stub
             37         stage = new Stage(480800true);
             38         
             39         ballTexture = new Texture(Gdx.files.internal("data/ball.png"));
             40         starTexture = new Texture(Gdx.files.internal("data/star.png"));
             41         
             42         Gdx.input.setInputProcessor(this);
             43     }
             44 
             45     private void makeStar(boolean star, int x, int y, int size) {
             46         Image img = null;
             47         
             48         if (star == true) {
             49             img = new Image("star", starTexture);
             50         }
             51         else {
             52             img = new Image("ball", ballTexture);
             53             if(size > 24)
             54                 size -= 24;
             55         }
             56         img.x = x;
             57         img.y = y;
             58         img.width = size;
             59         img.height = size;
             60         
             61         this.addAction(img);
             62         
             63         stage.addActor(img);        
             64     }
             65     
             66     private void addAction(final Image img) {
             67         
             68         int duration = MathUtils.random(360);
             69         MoveTo moveto = MoveTo.$(img.x, 800, duration);
             70         moveto.setCompletionListener(new OnActionCompleted() {
             71             public void completed(Action action) {
             72                 stage.removeActor(img);
             73             }
             74         });
             75         
             76         int rotate = MathUtils.random(360);        
             77         float scale = MathUtils.random(0.5f2.0f);
             78         float fade = MathUtils.random(1.0f);
             79         Action action = Parallel.$(
             80                 moveto,
             81                 ScaleTo.$(scale, scale, duration),
             82                 RotateTo.$(rotate, duration),
             83                 FadeTo.$(fade, duration)
             84                 );
             85         
             86         img.action(action);        
             87     }
             88     
             89     public void render() {
             90         Gdx.gl.glClearColor(0,0,0,0);
             91         Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
             92         
             93         float delta = Gdx.graphics.getDeltaTime();
             94         
             95         int roll = (int)(delta * 1000000);
             96         if (roll % 15 == 0) {
             97             makeStar(MathUtils.randomBoolean(), MathUtils.random(0480), MathUtils.random(064), MathUtils.random(1064));
             98         }
             99         
            100         stage.act(delta);
            101         stage.draw();
            102     }
            103     
            104     public void dispose() {
            105         stage.dispose();
            106         ballTexture.dispose();
            107         starTexture.dispose();
            108     }
            109     
            110     
            111     /* (non-Javadoc)
            112      * @see com.badlogic.gdx.InputProcessor#keyDown(int)
            113      */
            114     @Override
            115     public boolean keyDown(int arg0) {
            116         // TODO Auto-generated method stub
            117         return false;
            118     }
            119 
            120     /* (non-Javadoc)
            121      * @see com.badlogic.gdx.InputProcessor#keyTyped(char)
            122      */
            123     @Override
            124     public boolean keyTyped(char arg0) {
            125         // TODO Auto-generated method stub
            126         return false;
            127     }
            128 
            129     /* (non-Javadoc)
            130      * @see com.badlogic.gdx.InputProcessor#keyUp(int)
            131      */
            132     @Override
            133     public boolean keyUp(int arg0) {
            134         // TODO Auto-generated method stub
            135         return false;
            136     }
            137 
            138     /* (non-Javadoc)
            139      * @see com.badlogic.gdx.InputProcessor#scrolled(int)
            140      */
            141     @Override
            142     public boolean scrolled(int arg0) {
            143         // TODO Auto-generated method stub
            144         return false;
            145     }
            146 
            147     /* (non-Javadoc)
            148      * @see com.badlogic.gdx.InputProcessor#touchDown(int, int, int, int)
            149      */
            150     @Override
            151     public boolean touchDown(int arg0, int arg1, int arg2, int arg3) {
            152         // TODO Auto-generated method stub
            153         return false;
            154     }
            155 
            156     /* (non-Javadoc)
            157      * @see com.badlogic.gdx.InputProcessor#touchDragged(int, int, int)
            158      */
            159     @Override
            160     public boolean touchDragged(int arg0, int arg1, int arg2) {
            161         // TODO Auto-generated method stub
            162         
            163         makeStar(MathUtils.randomBoolean(), arg0, 800 - arg1, MathUtils.random(1064));
            164         
            165         return false;
            166     }
            167 
            168     /* (non-Javadoc)
            169      * @see com.badlogic.gdx.InputProcessor#touchMoved(int, int)
            170      */
            171     @Override
            172     public boolean touchMoved(int arg0, int arg1) {
            173         // TODO Auto-generated method stub
            174         return false;
            175     }
            176 
            177     /* (non-Javadoc)
            178      * @see com.badlogic.gdx.InputProcessor#touchUp(int, int, int, int)
            179      */
            180     @Override
            181     public boolean touchUp(int arg0, int arg1, int arg2, int arg3) {
            182         // TODO Auto-generated method stub
            183         return false;
            184     }
            185 
            186 }
            187 

            posted on 2011-06-03 00:53 codejie 閱讀(2932) 評(píng)論(2)  編輯 收藏 引用 所屬分類(lèi): 輪子精神G7

            評(píng)論

            # re: LIBGDX: Star.apk 2011-06-10 14:11 haolly

            最近玩ipad,對(duì)安卓興趣少少。。。。。。  回復(fù)  更多評(píng)論   

            # re: LIBGDX: Star.apk 2011-06-10 14:45 codejie

            @haolly
            嘿嘿。。我也會(huì)iPAD開(kāi)發(fā)哦,要不要給你搞個(gè)IOS版本的(說(shuō)說(shuō)而已,libgdx不支持IOS的。哇哈哈。。。)  回復(fù)  更多評(píng)論   

            公告

            Using C++

            導(dǎo)航

            統(tǒng)計(jì)

            留言簿(73)

            隨筆分類(lèi)(513)

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            狠狠色丁香久久婷婷综合_中| 国内精品久久国产大陆| 色综合久久88色综合天天 | 久久se这里只有精品| 国产精品久久久久久久久软件| 亚洲国产成人久久综合区| 亚洲AV无码一区东京热久久| 久久精品一区二区国产| 一本色道久久88综合日韩精品 | 日本精品一区二区久久久| 国产欧美久久久精品影院| 99re久久精品国产首页2020| 国产精品99久久久久久猫咪| 午夜不卡久久精品无码免费| 国产精品美女久久久久av爽| 久久狠狠高潮亚洲精品| 久久99亚洲网美利坚合众国| 国产精品久久久久乳精品爆| 久久久久久久波多野结衣高潮 | 久久婷婷成人综合色综合| 热久久这里只有精品| 久久男人Av资源网站无码软件| 一本大道久久香蕉成人网| 久久精品人妻一区二区三区| 99久久综合狠狠综合久久止| 久久婷婷五月综合色高清| 亚洲狠狠婷婷综合久久蜜芽| 性做久久久久久久久老女人| 国产精品九九久久免费视频| 久久最新精品国产| 91精品国产91久久综合| 亚洲AV无码久久精品蜜桃| 精品一二三区久久aaa片| 99精品国产99久久久久久97| 久久人妻少妇嫩草AV蜜桃| 久久久久久久免费视频| 久久人人青草97香蕉| 欧美日韩久久中文字幕| 久久婷婷色综合一区二区| 亚洲欧洲久久久精品| 99久久国产精品免费一区二区|