Exploder.cpp
资源名称:g.rar [点击查看]
上传用户:laitongbao
上传日期:2021-02-20
资源大小:8176k
文件大小:1k
源码类别:

射击游戏

开发平台:

Visual C++

  1. // Exploder.cpp: implementation of the Exploder class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "Exploder.h"
  6. //////////////////////////////////////////////////////////////////////
  7. // Construction/Destruction
  8. //////////////////////////////////////////////////////////////////////
  9. Particle_Emit *g_explode;
  10. P_Resistance  *g_resistance;
  11. Exploder::Exploder(float particle_size,int numParticles,float speed)
  12. {
  13. static bool init = false;
  14. if(!init)
  15. {
  16.  g_explode = (Particle_Emit*)g_tree->AddObject( &Particle_Emit("Exploder",5.f,2.f,"Fire/explode1.bmp",
  17. 0xffffffff,0x00000000,VECTOR3()),(NodeObject*)NULL);
  18.  g_resistance = (P_Resistance*)g_tree->AddObject(new P_Resistance("exp_resis"),(NodeObject*)NULL);
  19.  g_resistance->AddObject(g_explode);
  20. init = true;
  21. }
  22. g_resistance->SetPower(0.05f);
  23. this->emit = g_explode;
  24. exploded = false;
  25. this->particle_size =particle_size ;
  26. this->numParticles = numParticles;
  27. this->speed  = speed;
  28. }
  29. Exploder::Explode(VECTOR3 pos)//只能爆炸一次,pos设置爆炸位置
  30. {
  31. if(!exploded)
  32. { TransitionController::SetWorldPosition(emit,pos);
  33. emit->SetSize(particle_size);
  34. emit->Emit(VECTOR3(speed,0.f,0.f),numParticles,true,1.f);
  35. exploded = true;
  36. }
  37. }
  38. void Exploder::Reset()
  39. {
  40. exploded = false;
  41. }
  42. Exploder::~Exploder()
  43. {
  44. }