Android应用libGDX引擎系列(二)-libGDX 入门精要

Android应用libGDX引擎系列(二)-libGDX 入门精要,第1张

by AlexQ ( email alexq_andr@163.com )

一个作为引擎和游戏基础的高性能,跨平台的游戏开发框架。这个框架允许我们我们专注于基础而不是游戏引擎的新的特性。它具有很棒的灵活性。

libGDX 基于如此多的第三方库:

支持格式:mp3、ogg、wav等。

(1)clear() 方法:清空和删除所有已加载资源和预加载队列。

(2)containsAsset(T asset) :返回的是一个布尔类型,检测是否加载了否个资源

(3)finishLoading() : 所有资源加载完成后,结束加载资源,也可以手动设置加载到某一项结束加载。

(3)getAssetFileName(T asset) :获取资源名字,得到的是一个String类型的文件。

(4)getLoadedAssets() :获取已经加载的资源数量。

(5)getProgress() :获取加载进度,返回一个0 - 1之间的小数,这个一般可以用作制作进度条。

(6)isLoaded(java.lang.String fileName) :返回的是一个布尔类型,检测你传入的文件是否已经被加载了,一般使用的if判断语句中。

(7)load(java.lang.String fileName, java.lang.Class type) :将已传入的文件名和类型加入到预加载队列,为了防止名字和类型重复,这里需要将名字和类型都传入,常用。

(8)setLoader(java.lang.Class type, AssetLoader loader) :设置加载器,其实AssetManager类中包装了需要Assetloader对象,这样才能完成不同类型的文件的加载,当然AssetManager也可以加入加载器。

(9)unload(java.lang.String fileName) :卸载资源,如果某个资源不使用了,就可以卸载该资源,这样有利于游戏流畅性。

(10)update():加载资源,实际上Load方法其实只是将预加载的资源加载到了预加载队列,实质上并没有加载资源,使用update()方法才会加载资源,调用该方法才能,使不断加载那写储存在预加载对了中的资源。

(1)加载大部分资源采用异步加载的方式,这样就能在加载的同时不阻塞渲染进程.

(2)实现了引用计数,当A和B都依赖C素材的时候,C只有在A,B都销毁了才会销毁.这也意味着即使一个资源加载了很多次,在内存中也之后一份.

(3)使用一个单一管理器来实现管理所有素材.

(4)可以实现加载素材时占用的系统内存。

关于这个例子编辑器,个人推荐看看我下面提到的视频,里面有专门讲粒子编辑器使用的课程,比较直观。

官方网站上对软件中的各个参数的解释如下:

原文链接 http://doc.mapeditor.org/en/latest/manual/layers/

术语对照:

Tiled地图支持多种内容(content),这些内容(content)放在在许多不同的图层中。最常见的图层是Tiled图层和对象图层。还有一个Image图层,用来将单一的前景/背景图片放入到地图中。图层的顺序决定了内容的渲染顺序。

图层可以设置为“不可见”,“部分可见”。图层也可以被“锁定”。图层也有“偏移”。(这句话不是很懂。。。 “位移”可以用来将不同图层之间进行定位,比如模拟深度。)

眼睛图标和锁图标显示了各图层的可见性和锁定状态。

可以用Group图层来组织各图层的层次关系。这样在存在大量图层的情况下非常有用。

Tile图层提供了一种用存储Tile数据的方法,TIle数据用来填充大面积区域。Tile数据是简单的数组,只包含了Tile的索引,因此每个位置不能存储额外的信息。仅有的额外信息是少量的标志位,这些标志位允许图形的垂直平铺,水平或者反对角翻转(用于支持90度增量旋转)。

渲染每个Tile层所需的信息与地图一起储存。该地图基于方向和其他属性来指定Tile的位置和渲染顺序。

尽管只能够引用tile,tile层也可用于定义您级别中的各种非图形信息。 通常可以使用特殊的tile set来传达碰撞信息,并且任何类型的不需要自定义属性并且始终与网格对齐的对象也可以被放置在瓦片层上。

Oject 层非常有用,因为对象可以存储很多中 Tile 层不能存储的信息。

Objects 可以自由摆放,缩放,旋转。他们可以有独立的自定义属性。

目前有很多Objects:

所有Objects都可以被命名。在这种情况下,他们的名字可以在他们上访的标签中显示(默认只有选中的Objects)。Objects可以被指定一种类型,这非常有用,因为可以给予类型去指定标签的颜色和可用的自定义属性。对于Tile Objects来说,类型可以从他们的Tile继承。

对于大多数地图类型来说,Objects是基于像素去定位的。唯一的例外是 Isometric地图(不是isometric staggered).对于isometri地图来说,他们的位置被存储在投影坐标中。如果你在等距游戏中为对象使用不同的坐标空间,则需要对应的转换这些坐标。

Object的宽和高也基本上基于像素储存。Isometric地图不懂。。。。

Image层提供了一种在地图中包含单一前景/背景图片的快速方法。当前还作用不大,因为如果你将图片作为Tilesets加入,并放在Tile Objects, 你可以自由的缩放和旋转图片。

使用Image层的唯一优点是避免在使用“选择对象”工具时选择/拖动图像。 但是,从Tiled 1.1版本起,也可以通过锁定包含要避免交互的图块对象的对象层来实现。

Group 层类似于文件夹的形式,可以用来将各层组织起来。当地图中包含大量的图层时,这个功能较为有用。

Group层的可见性,透明图,偏移和锁定属性会应用于所有的子层。

可以使用鼠标将图层轻松地拖入group中。 提升层/下层动作还允许移动层进出组。

Layers can be easily dragged in and out of groups with the mouse. The Raise Layer / Lower Layer actions also allow moving layers in and out of groups.

层可以有更多强大的功能:

如果您喜欢任何这些计划,请通过成为顾客来帮助我更快地到达这个计划。 我得到的支持越多,我可以花更多的时间来改善Tiled!

Working with Layers

A Tiled map supports various sorts of content, and this content is organized into various different layers. The most common layers are the Tile Layer and the Object Layer. There is also an Image Layer for including simple foreground or background graphics. The order of the layers determines the rendering order of your content.

Layers can be hidden, made only partially visible and can be locked. Layers also have an offset, which can be used to position them independently of each other, for example to fake depth.

Layers View

The eye and lock icon toggle the visibility and locked state of a layer respectively.

You use Group Layers to organize the layers into a hierarchy. This makes it more comfortable to work with a large amount of layers.

Tile Layers

Tile layers provide an efficient way of storing a large area filled with tile data. The data is a simple array of tile references and as such no additional information can be stored for each location. The only extra information stored are a few flags, that allow tile graphics to be flipped vertically, horizontally or anti-diagonally (to support rotation in 90-degree increments).

The information needed to render each tile layer is stored with the map, which specifies the position and rendering order of the tiles based on the orientation and various other properties.

Despite only being able to refer to tiles, tile layers can also be useful for defining various bits of non-graphical information in your level. Collision information can often be conveyed using a special tileset, and any kind of object that does not need custom properties and is always aligned to the grid can also be placed on a tile layer.

Object Layers

Object layers are useful because they can store many kinds of information that would not fit in a tile layer. Objects can be freely positioned, resized and rotated. They can also have individual custom properties. There are many kinds of objects:

Rectangle - for marking custom rectangular areas

Ellipse - for marking custom ellipse or circular areas

Polygon - for when a rectangle or ellipse doesn’t cut it (often a collision area)

Polyline - can be a path to follow or a wall to collide with

Tile - for freely placing, scaling and rotating your tile graphics

Text - for custom text or notes (since Tiled 1.0)

All objects can be named, in which case their name will show up in a label above them (by default only for selected objects). Objects can also be given a type, which is useful since it can be used to customize the color of their label and the available custom properties for this object type. For tile objects, the type can be inherited from their tile.

For most map types, objects are positioned in plain pixels. The only exception to this are isometric maps (not isometric staggered). For isometric maps, it was deemed useful to store their positions in a projected coordinate space. For this, the isometric tiles are assumed to represent projected squares with both sides equal to the tile height. If you’re using a different coordinate space for objects in your isometric game, you’ll need to convert these coordinates accordingly.

The object width and height is also mostly stored in pixels. For isometric maps, all shape objects (rectangle, ellipse, polygon and polyline) are projected into the same coordinate space described above. This is based on the assumption that these objects are generally used to mark areas on the map.

Image Layers

Image layers provide a way to quickly include a single image as foreground or background of your map. They are currently not so useful, because if you instead add the image as a Tileset and place it as a Tile Object, you gain the ability to freely scale and rotate the image.

The only advantage of using an image layer is that it avoids selecting / dragging the image while using the Select Objects tool. However, since Tiled 1.1 this can also be achieved by locking the object layer containing the tile object you’d like to avoid interacting with.

New in Tiled 1.0

Group Layers

Group layers work like folders and can be used for organizing the layers into a hierarchy. This is mainly useful when your map contains a large amount of layers.

The visibility, opacity, offset and lock of a group layer affects all child layers.

Layers can be easily dragged in and out of groups with the mouse. The Raise Layer / Lower Layer actions also allow moving layers in and out of groups.

Future Extensions

There are many ways in which the layers can be made more powerful:

Ability to lock individual objects (#828).

Moving certain map-global properties to the Tile Layer (#149). It would be useful if one map could accommodate layers of different tile sizes and maybe even of different orientation.

If you like any of these plans, please help me getting around to it faster by becoming a patron. The more support I receive the more time I can afford to spend improving Tiled!


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11184151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存