本篇包括虚拟键盘,粒子系统

1虚拟键盘

分为两种,一种是单个虚拟键盘,另一种是多个方位虚拟键盘

1)加载虚拟键盘所需要的图片资源

	private BitmapTextureAtlas mOnScreenControlTexture;
private ITextureRegion mOnScreenControlBaseTextureRegion;
private ITextureRegion mOnScreenControlKnobTextureRegion;
 this.mOnScreenControlTexture = new BitmapTextureAtlas(this.getTextureManager(), 256, 128, TextureOptions.BILINEAR);
  this.mOnScreenControlBaseTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mOnScreenControlTexture, this, "onscreen_control_base.png", 0, 0);
  this.mOnScreenControlKnobTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mOnScreenControlTexture, this, "onscreen_control_knob.png", 128, 0);
  this.mOnScreenControlTexture.load();

2.1)单个虚拟键盘

   
final AnalogOnScreenControl analogOnScreenControl = new AnalogOnScreenControl(0, CAMERA_HEIGHT - this.mOnScreenControlBaseTextureRegion.getHeight(), this.mCamera, this.mOnScreenControlBaseTextureRegion, this.mOnScreenControlKnobTextureRegion, 0.1f, 200, this.getVertexBufferObjectManager(), new IAnalogOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
//pValueX	,pVlueY在[-1,1]之间,坐标系pValueX ,pVlueY交集就是方位啦		}

			@Override
public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
//里边的小的被点击时调用 }
});
analogOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
analogOnScreenControl.getControlBase().setAlpha(0.5f);
analogOnScreenControl.getControlBase().setScaleCenter(0, 128);
analogOnScreenControl.getControlBase().setScale(1.25f);
analogOnScreenControl.getControlKnob().setScale(1.25f);
analogOnScreenControl.refreshControlKnobPosition(); scene.setChildScene(analogOnScreenControl);

2.2多个虚拟键盘,下边的是两个

final AnalogOnScreenControl velocityOnScreenControl = new AnalogOnScreenControl(x1, y1, this.mCamera, this.mOnScreenControlBaseTextureRegion, this.mOnScreenControlKnobTextureRegion, 0.1f, this.getVertexBufferObjectManager(), new IAnalogOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
physicsHandler.setVelocity(pValueX * 100, pValueY * 100);
} @Override
public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
/* Nothing. */
}
});
velocityOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
velocityOnScreenControl.getControlBase().setAlpha(0.5f); scene.setChildScene(velocityOnScreenControl); /* Rotation control (right). */
final float y2 = (this.mPlaceOnScreenControlsAtDifferentVerticalLocations) ? 0 : y1;
final float x2 = CAMERA_WIDTH - this.mOnScreenControlBaseTextureRegion.getWidth();
final AnalogOnScreenControl rotationOnScreenControl = new AnalogOnScreenControl(x2, y2, this.mCamera, this.mOnScreenControlBaseTextureRegion, this.mOnScreenControlKnobTextureRegion, 0.1f, this.getVertexBufferObjectManager(), new IAnalogOnScreenControlListener() {//0.1f触摸响应时间为0.1秒 @Override
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
if(pValueX == x1 && pValueY == x1) {
face.setRotation(x1);
} else {
face.setRotation(MathUtils.radToDeg((float)Math.atan2(pValueX, -pValueY)));
}
} @Override
public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
/* Nothing. */
}
});
rotationOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
rotationOnScreenControl.getControlBase().setAlpha(0.5f); velocityOnScreenControl.setChildScene(rotationOnScreenControl);//两个键盘的关系

2粒子系统

1)粒子图片资源

	this.mBitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mParticleTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "particle_point.png", 0, 0); this.mBitmapTextureAtlas.load();

2)粒子类型

	final CircleOutlineParticleEmitter particleEmitter = new CircleOutlineParticleEmitter(ParticleSystemSimpleExample.CAMERA_WIDTH * 0.5f, ParticleSystemSimpleExample.CAMERA_HEIGHT * 0.5f + 20, 80);//粒子类型

3)粒子工场产生的粒子类型,数量等

final SpriteParticleSystem particleSystem = new SpriteParticleSystem(particleEmitter, 60, 60, 360, this.mParticleTextureRegion, this.getVertexBufferObjectManager());//粒子工厂,参数,60,60是粒子的最大与最小生成速率

4)粒子的行为方式(旋转,颜色,透明度方面的变化)

		particleSystem.addParticleInitializer(new ColorParticleInitializer<Sprite>(1, 0, 0));
particleSystem.addParticleInitializer(new AlphaParticleInitializer<Sprite>(0));
particleSystem.addParticleInitializer(new BlendFunctionParticleInitializer<Sprite>(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE));
particleSystem.addParticleInitializer(new VelocityParticleInitializer<Sprite>(-2, 2, -20, -10));
particleSystem.addParticleInitializer(new RotationParticleInitializer<Sprite>(0.0f, 360.0f));
particleSystem.addParticleInitializer(new ExpireParticleInitializer<Sprite>(6)); particleSystem.addParticleModifier(new ScaleParticleModifier<Sprite>(0, 5, 1.0f, 2.0f));
particleSystem.addParticleModifier(new ColorParticleModifier<Sprite>(0, 3, 1, 1, 0, 0.5f, 0, 0));
particleSystem.addParticleModifier(new ColorParticleModifier<Sprite>(4, 6, 1, 1, 0.5f, 1, 0, 1));
particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>(0, 1, 0, 1));
particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>(5, 6, 1, 0));

5)加载粒子到Sence中

		scene.attachChild(particleSystem);

6)粒子中心开始位置,开闭等

particleEmitter.setCenter(x,y );
particleSystem.setParticlesSpawnEnabled(true);

andengine游戏引擎总结进阶篇1的更多相关文章

  1. andengine游戏引擎总结进阶篇2

    本篇包括瓦片地图,物理系统, 1瓦片地图 超级玛丽,冒险岛,魂斗罗等游戏主场景都有瓦片地图画成,它的作用可见一斑,它可以用tiled Qt软件画成,在辅助篇中讲讲解tiled Qt软件的使用 1)加载 ...

  2. andengine游戏引擎总结基础篇

      其他的游戏引擎知道的不是很对,不过相对于学java的童鞋们来说,那是个不错的选择啦,这个发动机咋样,google去吧.基础篇包括图片,字体,音效,数据读取,会了这点,就会做简单的小游戏啦 对于游戏 ...

  3. 如何制作一款HTML5 RPG游戏引擎——第五篇,人物&人物特效

    上一次,我们实现了对话类,今天就来做一个游戏中必不可少的——人物类. 当然,你完全是可以自己写一个人物类,但是为了方便起见,还是决定把人物类封装到这个引擎里. 为了使这个类更有意义,我还给人物类加了几 ...

  4. 如何制作一款HTML5 RPG游戏引擎——第四篇,情景对话

    今天我们来实现情景对话.这是一个重要的功能,没有它,游戏将变得索然无味.所以我们不得不来完成它. 但是要知道,使用对话可不是一件简单的事,因为它内部的东西很多,比如说人物头像,人物名称,对话内容... ...

  5. 如何制作一款HTML5 RPG游戏引擎——第三篇,利用幕布切换场景

    开言: 在RPG游戏中,如果有地图切换的地方,通常就会使用幕布效果.所谓的幕布其实就是将两个矩形合拢,直到把屏幕遮住,然后再展开直到两个矩形全部移出屏幕. 为了大家做游戏方便,于是我给这个引擎加了这么 ...

  6. HTML5 RPG游戏引擎 地图实现篇

    一,话说全国年夜事   前没有暂看到lufy的专客上,有一名伴侣念要一个RPG游戏引擎,出于兴趣筹办入手做一做.因为我研讨lufylegend有冶时间了,对它有必然的依赖性,因而便筹办将那个引擎基于 ...

  7. HGE游戏引擎之实战篇,渐变的游戏开场

    #include <hge.h> #include "menuitem.h" //#include <hgefont.h> #include <hge ...

  8. Atitit 基于dom的游戏引擎

    Atitit 基于dom的游戏引擎 1. 添加sprite控件(cocos,createjs,dom)1 1.1.1. Cocos1 1.1.2. createjs1 1.1.3. Dom模式2 1. ...

  9. libgdx游戏引擎教程

    第一讲:libgdx游戏引擎教程(一)性能优良的游戏引擎—libgdx http://www.apkbus.com/android-57355-1-1.html 第二讲: libgdx游戏引擎教程(二 ...

随机推荐

  1. Memory Leak(内存泄漏)问题总结(转)

    最近听了一些关于Memory Leak(内存泄漏)的seminar,感觉有些收获,所以留个记录,并share给朋友. 1 什么是Memory Leak. Memory Leak是指由于错误或不完备的代 ...

  2. win7系统怎样备份

    利用系统自带的备份还原 1 这种方法的缺点是如果以后系统出现问题,无法进入系统的话,就无法恢复系统了.首先我们点击开始菜单,打开控制面板! 2 在控制面板中点击系统和安全! 3 我们选择备份和还原中的 ...

  3. Baidu Sitemap Generator插件使用图解教程

    这两天因为百度对本博客文章收录更新很慢,一直在网络查找真正的原因和解决方法.最终发现了柳城开发的Baidu Sitemap Generator WordPress插件,最终效果如果还需要验证一段时间. ...

  4. uva 10635 - Prince and Princess(LCS)

    题目连接:10635 - Prince and Princess 题目大意:给出n, m, k,求两个长度分别为m + 1 和 k + 1且由1~n * n组成的序列的最长公共子序列长的. 解题思路: ...

  5. 找出诡异的Bug:数据怎么存不进去

    带着学生做课程设计.程序一大,课程中做过了小项目,练过了分解动作,一到合起来了,难免还是要乱了分寸.事实上,实战的功夫,就是这样出来的.(课程设计指导视频链接(第36课时,3.18 银行系统开发).课 ...

  6. An Data-Scientist Prepares 《数据科学家的自我修养》

    从今天开始,博主将用大概1000天的时间记录自己学习并成为初级数据科学家(数据分析师)的心路历程. 包括数据科学家所必需的的基础知识:数学,统计,计算机,商业,沟通能力等. 希望博主能够在2017前完 ...

  7. C语言中的数据类型

    基本数据类型: int float double char void 派生数据类型: 数据类型修饰符 + 基本数据类型 = 派生数据类型 signed  和 unsigned 类型 unsigned ...

  8. git工作区和暂存区

    工作区(Working Directory) 就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区: 版本库(Repository) 工作区有一个隐藏目录.git,这个不算工作区, ...

  9. mysql的高级用法

    1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- 创建 备份 ...

  10. mysql 存在该记录则更新,不存在则插入记录的sql

    转 http://www.cnblogs.com/zeroone/articles/2298929.html , ‘yourname') ON DUPLICATE KEY UPDATE auto_na ...