首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex游戏发动机(PushButton)直接访问其它组件

2012-11-08 
flex游戏引擎(PushButton)直接访问其它组件直接访问其它组件,使用通用接口或直接访问If all else fails, y

flex游戏引擎(PushButton)直接访问其它组件

直接访问其它组件,使用通用接口或直接访问

If all else fails, you can directly access another component, either using a common interface or directly.

There are three methods to directly access a component in an entity. Use owner for your own entity, or lookup and use another entity to get components from somewhere else. The methods:

lookupComponentByName which looks up a single named component and returns it. lookupComponentByType which looks up a single component by type and returns it. lookupComponentsByType which finds all components that match the specified type.

Here's a simple example of directly accessing another component:

???

These functions are cheap, and calling them once a tick won't slow anything down. However, if you do need to store a permanent reference to a component, make sure to clear and re-establish it when onReset() is called. Otherwise, you may access stale data(无效陈旧数据) or cause a memory leak(内存泄露).

?????PBE.registerType(com.pblabs.rendering2D.DisplayObjectRenderer);