我试图让我的粒子随时间消失。不过,我似乎根本没有改变不透明度。知道问题出在哪里吗?
class Particle
{
public:
Particle();
Particle( ci::Vec2f );
void update();
void draw();
ci::Vec2f mLoc;
ci::Vec2f mDir;
float mVel;
float trans;
ci::ColorA mColor;
float mRadius;
float col_1,col_2,col_3;
};
void Particle::update()
{
mLoc+=mDir*mVel/2;
trans+=0.1;
mColor=ColorA(col_1,col_2,col_3,trans);
}
void Particle::draw()
{
gl::color(mColor);
gl::drawSolidCircle(mLoc,mRadius);
}
最佳答案
看起来您需要启用 alpha 混合,例如:
gl::enableAlphaBlending();
gl::color( mColor );
gl::drawSolidCircle(mLoc,mRadius);
gl::disableAlphaBlending();
此讨论有更多详细信息:http://forum.libcinder.org/topic/beginner-question-changing-alpha-of-a-texture#23286000000675041
关于c++ - 在 Cinder 中更改 alpha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15148059/