加载数字图片(cocos2dx)

1.方法一;使用LabelAtlas类

LabelAtlas* diceCount = LabelAtlas::create("100:", "nums_font.png", 14, 21, '0');

diceCount->setPosition(Point(visibleSize.width - 150, visibleSize.height / 2 - 50));

addChild(diceCount);

2.方法二:使用图片截取

Sprite *m_timeSpr = Sprite::create("mzi.png" , Rect(0,0,39.6,77));
m_timeSpr->setPosition(Vec2(AnenaSize.width*0.56, AnenaSize.height*0.73));
m_timeSpr->setVisible(false);
addChild(m_timeSpr); 

       更改截取面积:

m_timeSpr->setTextureRect(Rect(39.6*m_MatchTime,0,39.6,77));

猜你喜欢

转载自blog.csdn.net/u014206831/article/details/73849617