Snowman.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- #ifndef _SNOWMAN_HPP
- #define _SNOWMAN_HPP
- class Snowman: public MoveableObject
- {
- private:
-
-
- JSprite* mRun;
- JSprite* mDie;
- TileMap* mMap;
- int dead;
- u8 mTileInfo;
-
- public:
- Snowman(GameStatePlay* app);
- virtual ~Snowman();
- virtual void Update(float dt);
- virtual void HitLeft();
- virtual void HitRight();
- void Spawn(int col, int row);
- void die();
- int aLive();
- };
- void Snowman::die()
- {
- mCurrAnimation = mDie;
- dead = 1 ;
- }
- int Snowman::aLive()
- {
- if(dead==0)
- return 1;
- else
- return 0;
- }
- Snowman::Snowman(GameStatePlay* app): MoveableObject(app)
- {
- mMap = mApp->GetTileMap();
- mRun = new JSprite(mTexture, 108,108,110,185);
- mRun->SetHotSpot(0.0f, 190.0f);
- //mRun->AddFrame(105,105,110,160);
- //mRun->SetDuration(200.0f);
- mRun->StartAnimation();
- mDie = new JSprite(mTexture, 108,108,110,185);
- mDie->SetHotSpot(0.0f, 190.0f);
- mDie->AddFrame(14,135,74,153);
- mDie->AddFrame(0,296,131,184);
- mDie->SetDuration(200.0f);
- mDie->StartAnimation();
- mCurrAnimation = mRun;
- mYRenderOffset = 6.0f;
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mFlipped = false;
- mHScale = 0.80f;
- mVScale = 0.80f;
- mLeftAdjustment = 23;
- mRightAdjustment = 47;
- mHitLeftAdjustment = 2;
- mHitRightAdjustment = 46;
- mFallLeftAdjustment = -20;
- mFallRightAdjustment = -10;
- mRealHeight = 60;
- dead = 0;
- }
- Snowman::~Snowman()
- {
-
- delete mRun;
- }
- void Snowman::Update(float dt)
- {
-
- if(dead)
- dead++;
- if(dead<250)
- MoveableObject::Update(dt);
- else
- mActive = false;
- }
- void Snowman::Spawn(int col, int row)
- {
- mX = (float)(col<<TILE_SHIFT);
- mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;
- SetActive(true);
- }
- void Snowman::HitLeft()
- {
- mXVelocity = DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(true);
- }
- void Snowman::HitRight()
- {
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(false);
- }
- #endif