添加一个带有图片的分数模块。

如果我使用第一种方法,我会得到像这样的东西:

mydata.score = mydata.score + 5
scoreText.text = mydata.score
if mydata.score == 5 then
    score_5.isVisible=true
    score_5.x=score_title.x+score_title.width+135
end
if mydata.score == 10 then
    score_5.isVisible=false
    score_1.isVisible=true
    score_1.x=score_title.x+score_title.width+108
    score_0.isVisible=true
    score_0.x=score_title.x+score_title.width+135
end
if mydata.score == 15 then
    score_5.isVisible=false
    score_1.isVisible=true
    score_1.x=score_title.x+score_title.width+108
    score_0.isVisible=true
    score_0.x=score_title.x+score_title.width+135
end

有没有可能有一个“通用”的函数可以实现这个过程?

谢谢

点赞
用户2895078
用户2895078

你可以简单地使用图像,而无需使用精灵图表... 你需要通过始终显示5个图像,并在每次更新数字时使用removeSelf / newImageRect来处理它。屏幕可能会闪烁。

使用图像列表需要更多的设置:在这种情况下,您将有5个精灵,每个精灵知道显示从0到9的每个可能数字的序列,并需要请求每个精灵按照显示的数字运行正确的序列。

2014-04-21 14:09:26