加载level文件
使用LevelManager加载文件, 并管理它,提供接口加载和卸载level文件,你可以覆盖一些接口。
通过MXML加载
2.
<
pb:LevelFileReference
filename
=
"..Assets/Levels/level.pbelevel"
level
=
"0"
id
=
"myLevelReference"
/>
3.
<
pb:GroupReference
name
=
"Managers"
level
=
"0"
id
=
"managerGroup"
/>
4.
<
pb:GroupReference
name
=
"SpriteSheets"
level
=
"0"
id
=
"spriteSheetsGroup"
/>
5.
<
pb:GroupReference
name
=
"Objects"
level
=
"0"
id
=
"objectsGroup"
/>
6.
<
pb:GroupReference
name
=
"Everything"
level
=
"0"
id
=
"everythingGroup"
/>
7.
</
mx:Canvas
>
当LevelManager加载层,4个组获得对象,被LevelFileReference 、GroupReference2个类共享的level属性不过是索引定义加载的文件或层的编号
1.
2.
LevelManager.Instance.LoadLevel(0);
3.
LevelManager.Instance.Start();
当0层加载后,对象创建,游戏启动, LevelManager 分发基于加载和卸载level文件的事件
01.
02.
LevelManager.Instance.addEventListener(LevelEvent.LEVEL_LOADED_EVENT, levelLoadedHandler,
false
, 0,
true
);
03.
04.
LevelManager.Instance.LoadLevel(0);
05.
LevelManager.Instance.Start();
06.
private
function
levelLoadedHandler(event:LevelEvent):
void
07.
{
08.
09.
}
通过ActionScript加载
与通过MXML相似
01.
02.
LevelManager.Instance.AddFileReference(0,
"../Assets/Levels/level.pbelevel"
);
03.
LevelManager.Instance.AddGroupReference(0,
"Managers"
);
04.
LevelManager.Instance.AddGroupReference(0,
"SpriteSheets"
);
05.
LevelManager.Instance.AddGroupReference(0,
"Objects"
);
06.
LevelManager.Instance.AddGroupReference(0,
"Everything"
);
07.
08.
LoadManager.Instance.LoadLevel(0);
09.
LoadManager.Instance.Start();
对XML的其他使用
level文件和TemplateManager用来加载和实例XML数据,Serialization类可从XML中实例化,但建议使用TemplateManager
完整TAG列表
- things: The root tag.
- template: A child of the root tag, specifying that the contained XML is a template definition.
- entity: A child of the root tag, specifying that the contained XML is an entity definition.
- group: A child of the root tag, specifying that the contained XML is a group definition.
- component: A child of the template or entity tag, specifying that the contained XML is a component definition.
- objectReference: A child of the group tag, specifying the name of a template or object to instantiate with the group.
- groupReference: A child of the group tag, specifying the name of a group to instantiate with the parent group.
完整属性列表
-
name:
- On template tags, it specifies the name of the template.
- On entity tags, it specifies both the name of the entity in XML, and the name of the object that is instantiated from it.
- On group tags, it specifies the name of the group.
- On component tags, it specifies the name of the component once registered with its owning IEntity.
- On objectReference tags, it specifies the name of the template or entity to reference.
- On groupReference tags, it specifies the name of the group to reference.
- template: Exists on a template or entity tag and specifies the name of a template to inherit component definitions from.
- nameReference: Specifies the name of an entity to lookup and set on the tag.
- objectReference: Specifies the name of a template or entity to instantiate and set on the tag.
- entityName: Specifies the name of a template or entity to lookup and search for a compatible component to set on the tag.
- w: Specifies the name of a component to reference. If used without a componentReference attribute, the component is looked up on the same entity that this attribute is a part of.
-
type:
- On a component, specifies the fully qualified type to use to instantiate the component.
- On a field, specifies the type to use when instantiating the field for the parent tag.
- childType: Specifies the type to use when instantiating objects to add to an array or dictionary.
-
filename: For fields that hold resources, this lets you specify a file path. The field must be of a compatible type to the type of the resource as specified to the resource manager. The resource will be loaded and assigned to the field.
分享到:
相关推荐
NULL 博文链接:https://deepfuture.iteye.com/blog/709512
NULL 博文链接:https://deepfuture.iteye.com/blog/709889
NULL 博文链接:https://deepfuture.iteye.com/blog/709502
NULL 博文链接:https://deepfuture.iteye.com/blog/722156
帮助你快速了解PushButton的结构,尽快熟练应用
pushbutton engine是一个很好的flash游戏开发引擎,包含了常用的游戏组件,让设计师更注重游戏性的开发
PushButton Engine is a free framework for building Flash games. There are lots of great libraries for Flash game development. PushButton Engine makes it easy to bring those libraries together to build...
一款很强大的flash游戏开发引擎,分享下
一键式语音/停止技能 关于 假设有一个连接到Raspberry Pi的按钮,则会编写此Mycroft技能。 短按该按钮与说出唤醒词相同,然后允许用户说出命令。 长按与发出“停止”命令相同,因此将停止播放任何音频。...
原创pushbutton应用显示多行文字及数学公式-003v2.rar 因為修改太多~重新發帖~ 舊帖請至 https://www.ilovematlab.cn/thread-86806-1-4.html 查看 該函數應該已經很完善 如果有出現問題可至下方網址的日誌回報 ...
Flash2D+3D游戏引擎: Flixel 位图引擎; Pushbutton engine; FlashPunk 引擎; As3isolibj; Away3D; Alternativa3D; Flare3D; CopperCube; Sophie3D;
通过点击Qt中的pushbutton,可以弹出菜单,菜单选项是QAction,可以连接槽完成相应功能。Qt工程是基于Qt5.10.1 32位,Qt Creator 4.5.1(Community)
带Icon的自绘PushButton示例
ui->pushButton->setEnabled(false); myCom->setBaudRate(BAUD9600); myCom->setDataBits(DATA_8); myCom->setParity(PAR_NONE); myCom->setStopBits(STOP_1); myCom->setTimeout(500); connect(myCom,...
智能家居自动化:GIRA PUSHBUTTON SENSOR 4,GIRA TASTSENSOR 4.pdf
SW PUSHBUTTON SE PUSHBUTTON SW-PB Switch SW-SPDT SPDT Subminiature Toggle Switch, Right Angle Mounting, Vertical Actuation URF04 Ultrasonic wave distanc measure module VS1003b-Module MP3 module XTAL ...
IP178g交换芯片+PE68515变压器+双排RJ45座原理图库+PCB封装库(AD库),ALTIUM库文件,已在项目中使用,可以做为你的学习设计参考。 原理图库: Library Component Count : 15 Name Description ------------------...
pushbutton1_Callback.m
Header 3X2 Header, 3-Pin, Dual row Header 4 Header, 4-Pin Inductance LED PR9 MP2303A MP2303A NPN PJ-342 PJ-342B 6P 注意是双定 POWER2.5 Low Voltage Power Supply Connector Res1 Resistor SIM Card SIM ...
全志A20核心板配套开发底板Cadence原理图+ Pads2005格式PCB文件+转换后的AD格式原理图PCB文件: A20_DVK1_BASE_V16_Altium_Designer15.PcbDoc A20_DVK1_BASE_V16_BOM_20151015.xlsx A20_DVK1_BASE_V16_Gerber制板...