-- 把所有图片添加进一个列表中
-- 为0时使用的图片
local tabImageType =
{
"shop/shop_sp_goldlarge_1.png",
"shop/shop_sp_goldlarge_2.png",
"shop/shop_sp_goldlarge_3.png",
"shop/shop_sp_goldlarge_4.png",
"shop/shop_sp_goldlarge_5.png",
"shop/shop_sp_goldlarge_6.png",
}
-- 为1时使用的图片
local tabGoldImageType =
{
"shop/shop_sp_goldlarge_1.png",
"shop/shop_sp_goldlarge_2.png",
"shop/shop_sp_goldlarge_3.png",
"shop/shop_sp_goldlarge_4.png",
"shop/shop_sp_goldlarge_5.png",
"shop/shop_sp_goldlarge_6.png",
"shop/shop_sp_goldlarge_7.png",
"shop/shop_sp_goldlarge_8.png"
}
-- 根据ID来选择相对于图片,没有则选第一张
local imagetype = iteminfo["SortID"] or 1
imagefile = tabImageType[imagetype]
-- 图片
if nil ~= imagefile and cc.FileUtils:getInstance():isFileExist(imagefile) then
csb:getChildByName("sp_image"):setSpriteFrame(cc.Sprite:create(imagefile):getSpriteFrame())
end
也可参考:https://blog.csdn.net/chinahaerbin/article/details/45270309
https://blog.csdn.net/tonny_guan/article/details/45642691