fix: shader RetroTest by using new label

This commit is contained in:
Huabing.Xu 2014-03-05 14:41:13 +08:00
parent d1a0218a3b
commit b866a16503
2 changed files with 7 additions and 9 deletions

View File

@ -700,17 +700,15 @@ bool ShaderRetroEffect::init()
p->link();
p->updateUniforms();
auto director = Director::getInstance();
auto s = director->getWinSize();
_label = LabelBMFont::create("RETRO EFFECT", "fonts/west_england-64.fnt");
_label = Label::createWithBMFont("fonts/west_england-64.fnt","RETRO EFFECT");
_label->setAnchorPoint(Point::ANCHOR_MIDDLE);
_label->setShaderProgram(p);
p->release();
_label->setPosition(Point(s.width/2,s.height/2));
addChild(_label);
@ -725,10 +723,10 @@ bool ShaderRetroEffect::init()
void ShaderRetroEffect::update(float dt)
{
_accum += dt;
int i=0;
for(const auto &sprite : _label->getChildren()) {
i++;
int letterCount = _label->getStringLenght();
for (int i = 0; i < letterCount; ++i)
{
auto sprite = _label->getLetter(i);
auto oldPosition = sprite->getPosition();
sprite->setPosition(Point( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 ));

View File

@ -106,7 +106,7 @@ public:
bool init();
void update(float dt);
protected:
LabelBMFont* _label;
Label* _label;
float _accum;
};