libgdx的基本使用——演员与演出
来源:互联网 发布:淘宝二手工作站靠谱吗 编辑:程序博客网 时间:2024/04/28 23:32
直接贴本demo的核心代码,如果有什么不明白的,请参考前面的博客
package com.doodle.rdemo3;import com.badlogic.gdx.ApplicationListener;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.graphics.GL10;import com.badlogic.gdx.graphics.Texture;import com.badlogic.gdx.graphics.Texture.TextureFilter;import com.badlogic.gdx.math.MathUtils;import com.badlogic.gdx.scenes.scene2d.Action;import com.badlogic.gdx.scenes.scene2d.Stage;import com.badlogic.gdx.scenes.scene2d.actions.Actions;import com.badlogic.gdx.scenes.scene2d.ui.Image;public class FirstGame implements ApplicationListener {private Stage stage;private Texture texture;@Overridepublic void create() {stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);texture = new Texture(Gdx.files.internal("star.png"));texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); int maxWidth = Gdx.graphics.getWidth() - texture.getWidth(); int maxHeight = Gdx.graphics.getHeight() - texture.getHeight(); float duration = 4f; int i;for(i = 0 ; i < 20 ; ++i){Image image = new Image(texture);image.setX(MathUtils.random(0,maxWidth));image.setY(MathUtils.random(0,maxHeight));//!!!!每一个Action都尽量要设置duration,否则Action在一瞬间就完成了Action moveAction = Actions.sequence(Actions.moveTo(MathUtils.random(0, maxWidth),MathUtils.random(0,maxHeight),duration/2) , Actions.moveBy(MathUtils.random(0, maxWidth),MathUtils.random(0,maxHeight) ,duration / 2));Action rotateAction = Actions.rotateTo(360,duration);Action repeatAction = Actions.repeat(10,Actions.sequence( Actions.fadeIn(duration / 20) , Actions.fadeOut(duration / 20)));Action parallelAction = Actions.parallel(moveAction,rotateAction,repeatAction);image.addAction(parallelAction);stage.addActor(image);}Gdx.input.setInputProcessor(stage);}@Overridepublic void dispose() {// TODO Auto-generated method stub}@Overridepublic void pause() {// TODO Auto-generated method stub}@Overridepublic void render() {Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);stage.act(Gdx.graphics.getDeltaTime());stage.draw();}@Overridepublic void resize(int arg0, int arg1) {// TODO Auto-generated method stub}@Overridepublic void resume() {// TODO Auto-generated method stub}}
本demo远吗下载链接:http://download.csdn.net/detail/caihongshijie6/6978303
1 0
- libgdx的基本使用——演员与演出
- Libgdx的使用(6)——演员和演出
- libgdx基本使用——舞台与演员
- android游戏开发框架libgdx的使用(六)--演员和演出
- android游戏开发框架libgdx的使用(六)--演员和演出
- Libgdx的使用(4)——舞台和演员
- (libgdx小结)演员类的使用
- libgdx基本使用——中文显示与汉字绘制
- libgdx的基本使用(2)——绘制图形
- android游戏开发框架libgdx的使用(四)--舞台和演员
- android游戏开发框架libgdx的使用(四)--舞台和演员
- libgdx游戏引擎——libgdx粒子系统的使用
- Libgdx的使用(13)——杂谈Libgdx
- (libgdx)TexturePacker的基本使用(2)
- (libgdx)TexturePacker的基本使用(2)
- libGDX——舞台类的使用
- libgdx——常见UI的使用
- Libgdx的使用(12)——资源预加载与AssetManager的使用
- C/C++杂谈
- JAVA回调模式使用
- 题目1480:最大上升子序列和:动态规划
- 谷歌网页自动翻译,赞一个
- 动态设置Rave报表BMP图片文件
- libgdx的基本使用——演员与演出
- sqlSERVER常用函数及语法笔记
- k歌之王
- 查找二叉树
- Android开源项目发现---Spinner选择器与日历选择器篇(持续更新)
- 【iOS】UIViewController、UINavigationController与UITabBarController的整合使用
- KMP 模板 HDU 1711
- C#代码与javaScript函数的相互调用
- SQLite入门与分析(四)---Page Cache之事务处理(3)