-----------------------应用plist图片集中的图片---------------------------------
--1.
--add call back func
local function testTouchButton()
cclog("======= testTouchButton ====")
end
local sp = cc.Sprite:createWithSpriteFrameName("button_refresh.png");
sp:setPosition(100,500)
sp:registerScriptHandler(testTouchButton)
layerGame:addChild(sp,10);
--2.
-- 从图片集中添加炮台背景图片
local cannonBg = cc.Sprite:createWithSpriteFrame(self.cache:getSpriteFrame("Battery.png"))
-- 获得图片的宽与高
local rect = cannonBg:getTextureRect()
-- 设置图片位置
cannonBg:setPosition(cc.p(self.origin.x + self.visibleSize.width / 2, rect.height/ 2))
-- 将精灵添加到层中
--layerPlay:addChild(cannonBg)
bg:addChild(cannonBg)
-----------------------应用plist图片集中的图片---------------------------------
Lua笔记:应用plist图片集中的图片
最新推荐文章于 2019-11-13 00:21:36 发布
