cocos2d-x开发: 场景实体(entity)管理(4)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-16 20:03 点击:次
p>56 local rt = self.skeleton_armature_:convertToNodeSpace( cc.p( bounding_box.x + bounding_box.width, bounding_box.y + bounding_box.height ) )
p>57 local rb = self.skeleton_armature_:convertToNodeSpace( cc.p( bounding_box.x + bounding_box.width, bounding_box.y ) )
p>58
p>59 self.draw_debug_node_:clear()
p>60 self.draw_debug_node_:drawLine( lb, lt, self:get_debug_color() )
p>61 self.draw_debug_node_:drawLine( lt, rt, self:get_debug_color() )
p>62 self.draw_debug_node_:drawLine( rt, rb, self:get_debug_color() )
p>63 self.draw_debug_node_:drawLine( rb, lb, self:get_debug_color() )
p>64 end
p>65
p>66 return skeleton_entity
p>
p>
p>
p>我只是单纯的去获取创建Armatrue骨骼,没有加载资源,因为资源加载部分肯定是单独做的,这里只是顺便提一下.现在实现的部分代码只是单纯的画出了Boundingbox的区域,其他的还都没做.下面给出我的unittest部分的源码:
p>
p>
p> 1 local test_case = require "src.unittest.test_case"
p> 2 local skeleton_entity = require "src.firework.entity.skeleton_entity"
p> 3 local entity_manager = require "src.firework.entity.entity_manager"
p> 4 local visible_rect = require "src.firework.visible_rect"
p> 5 local test_entity_manager_case = class( "test_entity_manager_case", test_case )
p> 6
p> 7 local scene = cc.Scene:create()
p> 8 if cc.Director:getInstance():getRunningScene() then
p> 9 cc.Director:getInstance():replaceScene( scene )
p>10 else
p>11 cc.Director:getInstance():runWithScene( scene )
p>12 end
p>13
p>14 function test_entity_manager_case:run_impl()
p>15 ccs.ArmatureDataManager:getInstance():addArmatureFileInfo( "Hero/Hero0.png", "Hero/Hero0.plist", "Hero/Hero.ExportJson" )
p>16 local entity_manager_ins = entity_manager.new()
p>17 local skeleton_entity_ins = skeleton_entity.new( "Hero" )
p>18 skeleton_entity_ins:play( "loading" )
p>19 skeleton_entity_ins:set_anchor_point( cc.p( 0.5, 0.5 ) )
p>20 skeleton_entity_ins:set_position( visible_rect:center() )
p>21 skeleton_entity_ins:add_to_node( scene )
p>22
p>23 ccs.ArmatureDataManager:getInstance():addArmatureFileInfo( "tauren/tauren0.png", "tauren/tauren0.plist", "tauren/tauren.ExportJson" )
p>24 local skeleton_entity_ins1 = skeleton_entity.new( "tauren" )
p>25 skeleton_entity_ins1:play( "loading" )
p>26 skeleton_entity_ins1:set_anchor_point( cc.p( 0.5, 0.5 ) )
p>27 skeleton_entity_ins1:set_position( visible_rect:right_center() )
p>28 skeleton_entity_ins1:add_to_node( scene )
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>