Archived

This topic is now archived and is closed to further replies.

Simple peice of code that won't work.

This topic is 5892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

  



class PFXManager
{
public:
	vector<Effect> EffectList;
	vector<Effect>::iterator EffectListIt;
	void Explosion(int x, int y, float m);
	inline void DrawPFX();
};

void PFXManager::DrawPFX()
{
//	vector<Effect>::iterator EffectListEnd = EffectList.end(); 

//	for(EffectListIt = EffectList.begin(); EffectListIt != EffectListEnd; ++EffectListIt)

//	{

		EffectListIt = EffectList.begin();
		EffectListIt->Draw();
//	}

}


void PFXManager::Explosion(int x, int y, float m)
{
	Frame Frame1;
	Frame Frame2;
	Frame1.FrameType = EXPLOSION;
	Frame1.str = 255;
	Frame1.stg = 240;
	Frame1.stb = 240;
	Frame1.magnitude = m;
	Frame2.FrameType = EXPLOSION2;
	Frame2.str = 255;
	Frame2.stg = 210;
	Frame2.stb = 205;
	Frame2.magnitude = m;
	Effect Explosion;
	Explosion.AddFrame(Frame1);
	Explosion.AddFrame(Frame2);
	Explosion.xOrigin = x;
	Explosion.yOrigin = y;
	Explosion.Counter = 0;
	Explosion.LifeSpan = 200;

	EffectList.push_back(Explosion);
}
  
Can anyone tell me why this won''t work? I can create an effect in the same way without using the PFXManager class. -Forcas
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."

Share this post


Link to post
Share on other sites
It''s hard to tell without knowing how your classes behave.

Perhaps Effect or Frame have destructors that are changing their behaviour when Explosion completes.

''Nuff said. I''ll enjoy watching you live, demon.

Share this post


Link to post
Share on other sites
If you do something like this:
  
void Effect::AddFrame(Frame &frame)
{
frames[frameCount++] = &frame;
}

Then the frame object that the array references will be destroyed when Explosion returns. On the other hand, if you make a copy of the frame, then that wouldn''t explain anything.

''Nuff said. I''ll enjoy watching you live, demon.

Share this post


Link to post
Share on other sites