cocos2d-x_lua改變Sprite圖片

SylvanasYin發表於2016-02-27

local img_1= “image_1.png”
local img_2= “image_2.png”
local texture = display.loadImage(img_1)
local spriteFrame = display.newSpriteFrame(texture, cc.rect(0, 0, texture:getPixelsWide(), texture:getPixelsHigh()))
local sp = display.newSprite(spriteFrame)
sp:setPosition(cc.p(200,200)):addTo(panel_image)
local texture_new = display.loadImage(img_2)
local spriteFrame_new = display.newSpriteFrame(texture_new, cc.rect(0, 0, texture_new:getPixelsWide(), texture_new:getPixelsHigh()))
sp:setSpriteFrame(spriteFrame_new)

相關文章