龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 移动开发 > Android开发 >

andengine入门教程之学习笔记

时间:2012-12-24 21:59来源:未知 作者:admin 点击:
分享到:
例子中主程序.launcher.ExampleLauncher主要继承自ExpandableListActivity的列表, 这里主要定义了另个枚举public enum ExampleGroup和enum Example ,平时因为像他们这样使用比较少,值得学习。 代码如下

例子中主程序.launcher.ExampleLauncher主要继承自ExpandableListActivity的列表,
这里主要定义了另个枚举public enum ExampleGroup和enum Example ,平时因为像他们这样使用比较少,值得学习。

 代码如下 复制代码

enum Example {

// ===========================================================

// Elements

// ===========================================================

 

ANALOGONSCREENCONTROL(AnalogOnScreenControlExample.class, R.string.example_analogonscreencontrol),

ANALOGONSCREENCONTROLS(AnalogOnScreenControlsExample.class, R.string.example_analogonscreencontrols),

ANIMATEDSPRITES(AnimatedSpritesExample.class, R.string.example_animatedsprites),

AUGMENTEDREALITY(AugmentedRealityExample.class, R.string.example_augmentedreality),

AUGMENTEDREALITYHORIZON(AugmentedRealityHorizonExample.class, R.string.example_augmentedrealityhorizon),

AUTOPARALLAXBACKGROUND(AutoParallaxBackgroundExample.class, R.string.example_autoparallaxbackground),

BOUNDCAMERA(BoundCameraExample.class, R.string.example_boundcamera),

CHANGEABLETEXT(ChangeableTextExample.class, R.string.example_changeabletext),

COLLISIONDETECTION(CollisionDetectionExample.class, R.string.example_collisiondetection),

COLORKEYTEXTURESOURCEDECORATOR(ColorKeyTextureSourceDecoratorExample.class, R.string.example_colorkeytexturesourcedecorator),

COORDINATECONVERSION(CoordinateConversionExample.class, R.string.example_coordinateconversion),

CUSTOMFONT(CustomFontExample.class, R.string.example_customfont),

DIGITALONSCREENCONTROL(DigitalOnScreenControlExample.class, R.string.example_digitalonscreencontrol),

EASEFUNCTION(EaseFunctionExample.class, R.string.example_easefunction),

IMAGEFORMATS(ImageFormatsExample.class, R.string.example_imageformats),

LEVELLOADER(LevelLoaderExample.class, R.string.example_levelloader),

LINE(LineExample.class, R.string.example_line),

LOADTEXTURE(LoadTextureExample.class, R.string.example_loadtexture),

MENU(MenuExample.class, R.string.example_menu),

MODPLAYER(ModPlayerExample.class, R.string.example_modplayer),

MOVINGBALL(MovingBallExample.class, R.string.example_movingball),

MULTIPLAYER(MultiplayerExample.class, R.string.example_multiplayer),

MULTITOUCH(MultiTouchExample.class, R.string.example_multitouch),

MUSIC(MusicExample.class, R.string.example_music),

PAUSE(PauseExample.class, R.string.example_pause),

PATHMODIFIER(PathModifierExample.class, R.string.example_pathmodifier),

PARTICLESYSTEMNEXUS(ParticleSystemNexusExample.class, R.string.example_particlesystemnexus),

PARTICLESYSTEMCOOL(ParticleSystemCoolExample.class, R.string.example_particlesystemcool),

PARTICLESYSTEMSIMPLE(ParticleSystemSimpleExample.class, R.string.example_particlesystemsimple),

PHYSICSCONLLISIONFILTERING(PhysicsCollisionFilteringExample.class, R.string.example_physicscollisionfiltering),

PHYSICS(PhysicsExample.class, R.string.example_physics),

PHYSICSFIXEDSTEP(PhysicsFixedStepExample.class, R.string.example_physicsfixedstep),

PHYSICSJUMP(PhysicsJumpExample.class, R.string.example_physicsjump),

PHYSICSREVOLUTEJOINT(PhysicsRevoluteJointExample.class, R.string.example_physicsrevolutejoint),

PHYSICSREMOVE(PhysicsRemoveExample.class, R.string.example_physicsremove),

PINCHZOOM(PinchZoomExample.class, R.string.example_pinchzoom),

RECTANGLE(RectangleExample.class, R.string.example_rectangle),

REPEATINGSPRITEBACKGROUND(RepeatingSpriteBackgroundExample.class, R.string.example_repeatingspritebackground),

ROTATION3D(Rotation3DExample.class, R.string.example_rotation3d),

SHAPEMODIFIER(ShapeModifierExample.class, R.string.example_shapemodifier),

SHAPEMODIFIERIRREGULAR(ShapeModifierIrregularExample.class, R.string.example_shapemodifierirregular),

SOUND(SoundExample.class, R.string.example_sound),

SPLITSCREEN(SplitScreenExample.class, R.string.example_splitscreen),

SPRITE(SpriteExample.class, R.string.example_sprite),

SPRITEREMOVE(SpriteRemoveExample.class, R.string.example_spriteremove),

STROKEFONT(StrokeFontExample.class, R.string.example_strokefont),

SUBMENU(SubMenuExample.class, R.string.example_submenu),

TEXT(TextExample.class, R.string.example_text),

TEXTMENU(TextMenuExample.class, R.string.example_textmenu),

TEXTUREOPTIONS(TextureOptionsExample.class, R.string.example_textureoptions),

TMXTILEDMAP(TMXTiledMapExample.class, R.string.example_tmxtiledmap),

TICKERTEXT(TickerTextExample.class, R.string.example_tickertext),

TOUCHDRAG(TouchDragExample.class, R.string.example_touchdrag),

UNLOADRESOURCES(UnloadResourcesExample.class, R.string.example_unloadresources),

UPDATETEXTURE(UpdateTextureExample.class, R.string.example_updatetexture),

XMLLAYOUT(XMLLayoutExample.class, R.string.example_xmllayout),

ZOOM(ZoomExample.class, R.string.example_zoom),

 

BENCHMARK_ANIMATION(AnimationBenchmark.class, R.string.example_benchmark_animation),

BENCHMARK_PARTICLESYSTEM(ParticleSystemBenchmark.class, R.string.example_benchmark_particlesystem),

BENCHMARK_PHYSICS(PhysicsBenchmark.class, R.string.example_benchmark_physics),

BENCHMARK_SHAPEMODIFIER(ShapeModifierBenchmark.class, R.string.example_benchmark_shapemodifier),

BENCHMARK_SPRITE(SpriteBenchmark.class, R.string.example_benchmark_sprite),

BENCHMARK_TICKERTEXT(TickerTextBenchmark.class, R.string.example_benchmark_tickertext),

 

APP_CITYRADAR(CityRadarActivity.class, R.string.example_app_cityradar),

 

GAME_SNAKE(SnakeGameActivity.class, R.string.example_game_snake),

GAME_RACER(RacerGameActivity.class, R.string.example_game_racer);

 

// ===========================================================

// Constants

// ===========================================================

 

// ===========================================================

// Fields

// ===========================================================

 

public final Class<? extends BaseGameActivity> CLASS;

public final int NAMERESID;

 

// ===========================================================

// Constructors

// ===========================================================

 

private Example(final Class<? extends BaseGameActivity> pExampleClass, final int pNameResID) {

this.CLASS = pExampleClass;

this.NAMERESID = pNameResID;

}

 

// ===========================================================

// Getter & Setter

// ===========================================================

 

// ===========================================================

// Methods for/from SuperClass/Interfaces

// ===========================================================

 

// ===========================================================

// Methods

// ===========================================================

 

// ===========================================================

// Inner and Anonymous Classes

// ===========================================================

}

上面的public final Class<? extends BaseGameActivity> CLASS;表示任何继承自BaseGameActivity的类型,属于泛型,
因为andengine的例子程序都是继承自BaseGameActivity。

 代码如下 复制代码

public enum ExampleGroup {

// ===========================================================

// Elements

// ===========================================================

 

SIMPLE(R.string.examplegroup_simple,

Example.LINE, Example.RECTANGLE, Example.SPRITE, Example.SPRITEREMOVE),

MODIFIER_AND_ANIMATION(R.string.examplegroup_modifier_and_animation,

Example.MOVINGBALL, Example.SHAPEMODIFIER, Example.SHAPEMODIFIERIRREGULAR, Example.PATHMODIFIER, Example.ANIMATEDSPRITES, Example.EASEFUNCTION, Example.ROTATION3D ),

TOUCH(R.string.examplegroup_touch,

Example.TOUCHDRAG, Example.MULTITOUCH, Example.ANALOGONSCREENCONTROL, Example.DIGITALONSCREENCONTROL, Example.ANALOGONSCREENCONTROLS, Example.COORDINATECONVERSION, Example.PINCHZOOM),

PARTICLESYSTEM(R.string.examplegroup_particlesystems,

Example.PARTICLESYSTEMSIMPLE, Example.PARTICLESYSTEMCOOL, Example.PARTICLESYSTEMNEXUS),

MULTIPLAYER(R.string.examplegroup_multiplayer,

Example.MULTIPLAYER),

PHYSICS(R.string.examplegroup_physics,

Example.COLLISIONDETECTION, Example.PHYSICS, Example.PHYSICSFIXEDSTEP, Example.PHYSICSCONLLISIONFILTERING, Example.PHYSICSJUMP, Example.PHYSICSREVOLUTEJOINT, Example.PHYSICSREMOVE ),

TEXT(R.string.examplegroup_text,

Example.TEXT, Example.TICKERTEXT, Example.CHANGEABLETEXT, Example.CUSTOMFONT, Example.STROKEFONT),

AUDIO(R.string.examplegroup_audio,

Example.SOUND, Example.MUSIC, Example.MODPLAYER),

ADVANCED(R.string.examplegroup_advanced,

Example.SPLITSCREEN, Example.BOUNDCAMERA ), // Example.AUGMENTEDREALITY, Example.AUGMENTEDREALITYHORIZON),

BACKGROUND(R.string.examplegroup_background,

Example.REPEATINGSPRITEBACKGROUND, Example.AUTOPARALLAXBACKGROUND, Example.TMXTILEDMAP),

OTHER(R.string.examplegroup_other,

Example.PAUSE, Example.MENU, Example.SUBMENU, Example.TEXTMENU, Example.ZOOM , Example.IMAGEFORMATS, Example.TEXTUREOPTIONS, Example.COLORKEYTEXTURESOURCEDECORATOR, Example.LOADTEXTURE, Example.UPDATETEXTURE, Example.XMLLAYOUT, Example.LEVELLOADER),

APP(R.string.examplegroup_app,

Example.APP_CITYRADAR),

GAME(R.string.examplegroup_game,

Example.GAME_SNAKE, Example.GAME_RACER),

BENCHMARK(R.string.examplegroup_benchmark,

Example.BENCHMARK_SPRITE, Example.BENCHMARK_SHAPEMODIFIER, Example.BENCHMARK_ANIMATION, Example.BENCHMARK_TICKERTEXT, Example.BENCHMARK_PARTICLESYSTEM, Example.BENCHMARK_PHYSICS);

 

// ===========================================================

// Constants

// ===========================================================

 

// ===========================================================

// Fields

// ===========================================================

public final Example[] EXAMPLES;

public final int NAMERESID;

 

// ===========================================================

// Constructors

// ===========================================================

 

private ExampleGroup(final int pNameResID, final Example ... pExamples) {

this.NAMERESID = pNameResID;

this.EXAMPLES = pExamples;

}

 

// ===========================================================

// Getter & Setter

// ===========================================================

 

// ===========================================================

// Methods for/from SuperClass/Interfaces

// ===========================================================

 

// ===========================================================

// Methods

// ===========================================================

 

// ===========================================================

// Inner and Anonymous Classes

// ===========================================================

}

主程序就比较简单,不再介绍了。


精彩图集

赞助商链接