zoukankan      html  css  js  c++  java
  • quick cocos getBoundingBox的bug

    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
  • 相关阅读:
    升级到virtualbox2.1.4
    gentool 工具 modulerebuild
    解决man乱码问题
    关于HyperV的Linux驱动
    使用tmpfs优化firefox
    使用gmbox下载google歌曲
    升级到xorgserver1.5时出现的问题
    windows下使用where命令
    CSS中一些渐变效果与透明
    asp.net下密码框的一些小问题
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4316327.html
Copyright © 2011-2022 走看看