现在的位置: 首页 > 综合 > 正文

AndEngine Most important concepts

2013年08月02日 ⁄ 综合 ⁄ 共 2415字 ⁄ 字号 评论关闭
In this article, I will try to cover description, of the most important engine concepts. Brief information, such as description of most frequently used classes and their extensions.
1. AndEngine - Core Terminology (by  Nicolas Gramlich + updates and addons)

Engine:
The Engine make the game proceed in small discrete steps of time. The Engine manages to synchronize a periodic drawing and updating of the Scene, which contains all the content that your game is currently handling actively. You can use also subclasses:
  • LimitedFPSEngine - tries to achieve a specific amount of updates per second.

IResolutionPolicy:

An implementation of the IResolutionPolicy interface is part of the EngineOptions. It tells AndEngine how to deal with the different screen-sizes of different devices. I.e. RatioResolutionPolicy will maximize the SurfaceView to the limiting size of the screen,
while keeping a specific ratio. That means objects won't be distorted while the SurfaceView has the maximum size possible.
  • RatioResolutionPolicy - keep everything scaled in in proper ratio (disadvantage - black lines might occur)
  • FillResolutionPolicy - fill whole resolution (disadvantage - images might be stretched)

Camera:
A Camera defines the rectangle of the scene that is drawn on the screen, as not the whole scene is visible all the time. Usually there is one Camera per Scene. There are subclasses with more functions, example:
  • BoundCamera - you might specify bounds for your scene.
  • ZoomCamera - you might enable zooming, pinch zoom, and scrolling camera.

Scene:
The Scene class is the root container for all objects to be drawn on the screen. A Scene has a specific amount of Layers, which themselves can contain a (fixed or dynamic) amount of Entities. There are subclasses, like the CameraScene/HUD/MenuScene that are
drawing themselves to the same position of the Scene no matter where the camera is positioned to.
  • HUD - usage for example for score (it has to be all the time in the same position, follow camera changes)

Entity:
An Entitiy is an object that can be drawn, like Sprites, Rectangles, Text or Lines. An Entity has a position/rotation/scale/color/etc.
  • Sprite - entity with texture
  • TiledSprite - entity with tiled texture, you may switch between tiles.
  • AnimatedSprite - extension of the TiledSprite, you may animate tiles in specified intervals.

Texture:
A Texture is a 'image' in the memory of the graphics chip. On Android the width and height of a Texture has to be a power of 2 (in latest GLES2 this rule is not required, so its really useful to reduce memory usage)
Therefore AndEngine assembles a Texture from a couple of ITextureSources, so the space can be used better.

TextureRegion:
A TextureRegion defines a rectangle on the Texture. A TextureRegion is used by Sprites to let the system know what part of the big Texture the Sprite is showing.

抱歉!评论已关闭.