local scheduler = require(cc.PACKAGE_NAME .. ".scheduler") local TestSprite = class("TestSprite", function() return display.newSprite("#player_idle1.png") end) function TestSprite:ctor(map) local size= self:getBoundingBox() print(size.x) print(size.y) end return TestSprite -- -20 -28
local TestScene = class("TestScene", function() return display.newScene("TestScene") end) function TestScene:ctor() self.map_=cc.TMXTiledMap:create("map/map.tmx"); self:addChild(self.map_) --[[ local sp2= display.newSprite("#player_idle1.png",4*32+16,5*32+24) local spSize=sp2:getSpriteFrame():getRect() --local sp= display.newSprite("#player_idle1.png",4*32+16,5*32+spSize.height/2):addTo(self.map_) local sp=display.newSprite("#player_idle1.png") sp:setPosition(4*32+16,5*32+spSize.height/2) self.map_:addChild(sp) --cc.Sprite:getBoundingBox(). local aabb=sp:getBoundingBox() print(aabb.x) print(aabb.y) print(aabb.width) print(aabb.height) local sp3= display.newSprite("test/point.png",aabb.x,aabb.y):addTo(self) --transition.moveTo(self.map_, {x = -display.cx, y = 0, time = 1.5}) ]] local TestSprite=require("src/TestSprite") self.hero_=TestSprite.new(self.map_) self.hero_:setPosition(4*32+16,5*32+12) self.map_:addChild(self.hero_) local aabb=self.hero_:getBoundingBox() print(aabb.x) print(aabb.y) end return TestScene -- 124 144
时间: 2024-09-30 11:53:33