AndEngine----PathModifierExample学习之模仿《w》行走
来源:互联网 发布:网上邻居网络密码 编辑:程序博客网 时间:2024/05/17 07:13
防着Example中的代码写的,没有什么好说的!直接贴代码:
public class PathModifierMy extends SimpleBaseGameActivity {private int mCameraWidth = 0;private int mCameraHeight = 0;private RepeatingSpriteBackground mRepeatingSpriteBackground;private BitmapTextureAtlas mPlayer;private TiledTextureRegion mPlayerRegion;Path mPlayerPath;AnimatedSprite mPlayerAnimatedSprite;PathModifier mPathModifier;LoopEntityModifier mLoopEntityModifier;private void initCameraSize() {mCameraWidth = getResources().getDisplayMetrics().widthPixels;mCameraHeight = getResources().getDisplayMetrics().heightPixels;}@Overridepublic EngineOptions onCreateEngineOptions() {initCameraSize();Camera camera = new Camera(0, 0, mCameraWidth, mCameraHeight);return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,new RatioResolutionPolicy(mCameraWidth, mCameraHeight), camera);}@Overrideprotected void onCreateResources() {BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");mRepeatingSpriteBackground = new RepeatingSpriteBackground(mCameraWidth, mCameraHeight, getTextureManager(),AssetBitmapTextureAtlasSource.create(getAssets(),"gfx/background_grass.png"),getVertexBufferObjectManager());mPlayer = new BitmapTextureAtlas(getTextureManager(), 128, 128);mPlayerRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayer, this, "player.png", 0, 0, 3, 4);mPlayer.load();}@Overrideprotected Scene onCreateScene() {mEngine.registerUpdateHandler(new FPSLogger());Scene scene = new Scene();scene.setBackground(mRepeatingSpriteBackground);/* Create the face and add it to the scene. */mPlayerAnimatedSprite = new AnimatedSprite(10, 10, 48, 64,this.mPlayerRegion, this.getVertexBufferObjectManager());// 构造path,6为Path链接的次数,即后面to的个数,可以大于,但是不能小于mPlayerPath = new Path(6)// 初始点.to(10, 10)// 到第一个拐点.to(mCameraWidth / 4.0f, mCameraHeight - 64)// 到第二个拐点.to(mCameraWidth / 2.0f, mCameraHeight / 2.0f)// 到第三个拐点.to(3 * mCameraWidth / 4.0f, mCameraHeight - 64)// 到第四个拐点.to(mCameraWidth - 64, 10);mPathModifier = new PathModifier(30, mPlayerPath, null,mPathModifierListener, EaseSineInOut.getInstance());mLoopEntityModifier = new LoopEntityModifier(mPathModifier);mPlayerAnimatedSprite.registerEntityModifier(mLoopEntityModifier);scene.attachChild(mPlayerAnimatedSprite);return scene;}IPathModifierListener mPathModifierListener = new IPathModifierListener() {@Overridepublic void onPathWaypointStarted(PathModifier pPathModifier,IEntity pEntity, int pWaypointIndex) {switch (pWaypointIndex) {case 0:mPlayerAnimatedSprite.animate(new long[] { 200, 200, 200 }, 6,8, true);break;case 1:mPlayerAnimatedSprite.animate(new long[] { 200, 200, 200 }, 0,2, true);break;case 2:mPlayerAnimatedSprite.animate(new long[] { 200, 200, 200 }, 6,8, true);break;case 3:mPlayerAnimatedSprite.animate(new long[] { 200, 200, 200 }, 0,2, true);break;case 4:mPlayerAnimatedSprite.animate(new long[] { 200, 200, 200 }, 9,11, true);break;default:break;}}@Overridepublic void onPathWaypointFinished(PathModifier pPathModifier,IEntity pEntity, int pWaypointIndex) {}@Overridepublic void onPathStarted(PathModifier pPathModifier, IEntity pEntity) {Debug.d(" [onPathStarted] ");}@Overridepublic void onPathFinished(PathModifier pPathModifier, IEntity pEntity) {Debug.d(" [onPathFinished] ");}};}
- AndEngine----PathModifierExample学习之模仿《w》行走
- AndEngine之DEMO学习(十)PathModifierExample
- AndEngine----PathModifierExample学习
- AndEngine----CardinalSplineMoveModifierExample之模仿画<W>
- AndEngine Example(8):PathModifierExample
- AndEngine屏幕跟随人物行走
- AndEngine之DEMO学习(零)AndEngine结构
- AndEngine学习之路(一):AndEngine配置
- AndEngine之DEMO学习(一)LineExample
- AndEngine之DEMO学习(二)RectangleExample
- AndEngine之DEMO学习(三)SpriteExample
- AndEngine之DEMO学习(四)SpriteRemoveExample
- AndEngine之DEMO学习(五)SpriteBatchExample
- AndEngine之DEMO学习(六)MovingBallExample
- AndEngine之DEMO学习(七)EntityModifierExample
- AndEngine之DEMO学习(八)EntityModifierIrregularExample
- AndEngine之DEMO学习(九)CardinalSplineMoveModifierExample
- AndEngine之DEMO学习(十一)AnimatedSpritesExample
- C#调用C++的DLL搜集整理的所有数据类型转换方式
- socket学习第一节:服务器和客户端通信
- 程序员最关心的是什么
- juqery实现左边树
- Orcle 主键自增(序列sequence、触发器trigger、主键primary)
- AndEngine----PathModifierExample学习之模仿《w》行走
- ffmpeg解码流程 .
- 使用WindowManager进行progress提示
- Android 中LayoutInflater的使用
- Spring Test 整合 JUnit 4 使用总结
- jQuery中使用Ajax获取JSON格式数据
- 反射
- smartforms打印非常规纸
- Qt入门-打开和保存文件对话框