–Sprite类型
–[[
创建精灵(图片)
static Sprite*createWithSpriteFrameName(const std :: string & spriteFrameName)
Creates a sprite with an sprite frame name.
–]]
local img = cc.Sprite:createWithSpriteFrameName(“xiaowang.png”)
img:setPosition(100, 100)
layerGame:addChild(img)
–无效精灵名字,不知道为哈
–替换新的图片资源
local frame = cc.SpriteFrameCache:getInstance():getSpriteFrame(“xiaowang.png”)
img:setSpriteFrame(frame)
—输出显示为nil,原因未知,留作后续解决
–ImageView类型,CocosStudio中获取的图片按件类型为ImageView类型
local fishOne = taskbg:getChildByName(“xaowang”)
fishOne:setPosition(150,20)
–设置一个新的纹理(从一个文件名)到精灵。
–Sets a new texture (from a filename) to the sprite.
self.hei:setTexture(“poker/number/52.png”)
–正常 可以使用
– 加载plist资源文件
self.cache = cc.SpriteFrameCache:getInstance()
self.cache:addSpriteFrames(“game_element.plist”)
cc.SpriteFrameCache:getInstance():addSpriteFrames(“iconslotfish.plist”)