以下是一个完整的以xml组装游戏的实例:整个项目文件结构如下:

flash开源游戏引擎pushButton学习笔记(5)----以xml组装游戏

1、assets/Level/common.xml 文件为pushButton引擎当中的组件组装文件,以下为该文件代码:

 

<!DOCTYPE things PUBLIC "HJKHKJ" "PBEDTD.dtd">
<things>
    
<entity name="SpatialDB">
        
<component name="Manager" type="com.pblabs.box2D.Box2DManagerComponent">
            
        
</component>
    
</entity>
    
    
<entity name="Scene">
        
<component name="Scene" type="com.pblabs.rendering2D.DisplayObjectScene">
            
<trackObject componentReference="FeiJi"/>
            
<sceneViewName>MainApp</sceneViewName>
        
</component>
    
</entity>
    
    
    
    
<entity name="BG">
        
<component name="Spatial" type="com.pblabs.rendering2D.SimpleSpatialComponent">
            
<spatialManager componentReference="SpatialDB"/>
            
<position>
                
<x>0</x>
                
<y>0</y>
            
</position>
            
<size type="">
                
<x>896</x>
                
<y>640</y>
            
</size>
        
</component>
        
        
<component name="Render" type="com.pblabs.rendering2D.SpriteRenderer">
            
<fileName>
                assets/image/bgs.jpg
            
</fileName>
            
<positionProperty>@Spatial.position</positionProperty>
            
<sizeProperty>@Spatial.size</sizeProperty>
            
<scene componentReference="Scene"/>
        
</component>
    
</entity>
    
    
    
<entity name="FeiJi">
        
<component name="Spatial" type="com.pblabs.rendering2D.SimpleSpatialComponent">
            
<position>
                
<x>0</x>
                
<y>0</y>
            
</position>
            
<spatialManager componentReference="SpatialDB"/>
        
</component>
        
        
<component name="Render" type="com.pblabs.rendering2D.SpriteRenderer">
            
<fileName>assets/image/fanship.png</fileName>
            
<positionProperty>@Spatial.position</positionProperty>
            
<sizeProperty>@Spatial.size</sizeProperty>
            
<scene componentReference="Scene"/>
        
</component>
        
        
<component name="Controller" type="controller.FeijiController">
            
<positionReference>@Spatial.position</positionReference>
        
</component>
        
    
</entity>
    
    
    
<entity name="HuaHua">
        
<component name="Spatial" type="com.pblabs.rendering2D.SimpleSpatialComponent">
            
<position>
                
<x>-400</x>
                
<y>0</y>
            
</position>
            
<size type="">
                
<x>60</x>
                
<y>60</y>
            
</size>
            
<spatialManager componentReference="SpatialDB"/>
        
</component>
        
        
<component name="Render" type="com.pblabs.rendering2D.SpriteRenderer">
            
<fileName>assets/image/HH_baihe.png</fileName>
            
<positionProperty>@Spatial.position</positionProperty>
            
<sizeProperty>@Spatial.size</sizeProperty>
            
<scene componentReference="Scene"/>
        
</component>
        
<component name="Controller" type="controller.HuaHuaController">
            
<input childType="com.pblabs.engine.core.InputMap">
                
<GoUp>UP</GoUp>
                
<GoDown>DOWN</GoDown>
            
</input>
        
</component>
    
</entity>
    
    
<group name="Common">
        
<objectReference name="SpatialDB"/>
        
<objectReference name="Scene"/>
        
<objectReference name="BG"/>
        
<objectReference name="FeiJi"/>
        
<objectReference name="HuaHua"/>
    
</group>
</things>

相关文章: