|
|
定义一个oldParticle来拷贝构造函数Particles里的各项属性值
struct Position
{
float x;
float y;
float z;
};
struct Color
{
float R;
float G;
float B;
};
class Particles
{
public:
Particles(float x, float y, float z);
Particles(const Particles &p)
void Render();
bool dead;
private:
Position Pos;
Color Col;
float speed;
float speed_acc;
float alpha;
float alpha_dec;
float size;
};
//数据更新
if(fps==0) fps=30;
Particles oldParticle( *this );//(这句话是调用oldParticle的属性值,也就是在particles那里拷贝过来的属性值)
speed+=speed_acc;
Pos.y +=speed;
alpha-=alpha_dec;
size-=0.05f*(30/fps);
Pos.x +=-Pos.x/30.0f;
Pos.z +=-Pos.z/30.0f;
if(alpha<=0.0f) dead=true;
}
Particles: articles(float x, float y, float z)
{
Pos.x = x;
Pos.y = y;
Pos.z = z;
Col.R = 1.0f;
Col.G = 1.0f;
Col.B = 0.8f;
speed = 0.2f;
speed_acc = GetRandom(0.013f, 0.015f);
alpha = 1.0f;
alpha_dec = GetRandom(0.033f, 0.03301f);
size=4.0f;
dead = false;
}
Particles::Particles(const Particles &p){
this-> os.x = p.Pos.x;
this->Pos.y = p.Pos.y;
this->Pos.z = p.Pos.z;
this->Col.R = p.Col.R;
this->Col.G = p.Col.G;
this->Col.B = p.Col.B;
this->speed = p.speed;
this->speed_acc = p.speed_acc;
this->alpha = p.alpha;
this->alpha_dec = p.alpha_dec;
this->size = p.size;
this->dead = p.dead;
}
不知道哪里出了问题,哪位大哥帮我改下啊`最好能具体点..谢谢了 |
|