mirror of https://github.com/axmolengine/axmol.git
fix: shader RetroTest by using new label
This commit is contained in:
parent
d1a0218a3b
commit
b866a16503
|
@ -700,17 +700,15 @@ bool ShaderRetroEffect::init()
|
||||||
p->link();
|
p->link();
|
||||||
p->updateUniforms();
|
p->updateUniforms();
|
||||||
|
|
||||||
|
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto s = director->getWinSize();
|
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);
|
_label->setShaderProgram(p);
|
||||||
|
|
||||||
p->release();
|
p->release();
|
||||||
|
|
||||||
|
|
||||||
_label->setPosition(Point(s.width/2,s.height/2));
|
_label->setPosition(Point(s.width/2,s.height/2));
|
||||||
|
|
||||||
addChild(_label);
|
addChild(_label);
|
||||||
|
@ -725,10 +723,10 @@ bool ShaderRetroEffect::init()
|
||||||
void ShaderRetroEffect::update(float dt)
|
void ShaderRetroEffect::update(float dt)
|
||||||
{
|
{
|
||||||
_accum += dt;
|
_accum += dt;
|
||||||
|
int letterCount = _label->getStringLenght();
|
||||||
int i=0;
|
for (int i = 0; i < letterCount; ++i)
|
||||||
for(const auto &sprite : _label->getChildren()) {
|
{
|
||||||
i++;
|
auto sprite = _label->getLetter(i);
|
||||||
auto oldPosition = sprite->getPosition();
|
auto oldPosition = sprite->getPosition();
|
||||||
sprite->setPosition(Point( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 ));
|
sprite->setPosition(Point( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 ));
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
protected:
|
protected:
|
||||||
LabelBMFont* _label;
|
Label* _label;
|
||||||
float _accum;
|
float _accum;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue