仿照“我叫MT”的控件
代码如下:
local function createBanner()
local layerFarm = CCNode:create()
local cache = CCSpriteFrameCache:sharedSpriteFrameCache()
cache:addSpriteFramesWithFile("pic.plist")
local spritebatch = CCSpriteBatchNode:create("pic.png")
layerFarm:addChild(spritebatch)
local bg = CCSprite:createWithSpriteFrameName("bg.png")
spritebatch:addChild(bg)
cclog("The size of bg is: %0.2f, %0.2f", bg:getContentSize().width, bg:getContentSize().height)
local px = bg:getContentSize().width / 2;
local py = bg:getContentSize().height /2;
local head01 = CCSprite:createWithSpriteFrameName("head01.png")
spritebatch:addChild(head01)
head01:setAnchorPoint(ccp(0, 0.5));
head01:setPosition(-px, 0);
local lv = CCSprite:createWithSpriteFrameName("lv.png")