Mushroom.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- #ifndef _MUSHROOM_HPP_
- #define _MUSHROOM_HPP_
- class Mushroom: public MoveableObject
- {
- private:
-
- JSprite* mRun;
- TileMap* mMap;
- u8 mTileInfo;
-
- public:
- Mushroom(GameStatePlay* app);
- virtual ~Mushroom();
- virtual void Update(float dt);
- virtual void HitLeft();
- virtual void HitRight(int left, int right, int row);
- void Spawn(int col, int row);
- };
- Mushroom::Mushroom(GameStatePlay* app): MoveableObject(app)
- {
- mMap = mApp->GetTileMap();
- mRun = new JSprite(mTexture, 205,245,101,90);
- mRun->SetHotSpot(0.0f, 77.0f);
- mRun->AddFrame(409,245,101,90);
- mRun->AddFrame(309,245,101,90);
- mRun->SetDuration(200.0f);
- mRun->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;
- }
- Mushroom::~Mushroom()
- {
-
- delete mRun;
- }
- void Mushroom::Update(float dt)
- {
-
- MoveableObject::Update(dt);
- }
- void Mushroom::Spawn(int col, int row)
- {
- mX = (float)(col<<TILE_SHIFT);
- mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;
- SetActive(true);
- }
- void Mushroom::HitLeft()
- {
- mXVelocity = DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(true);
- }
- void Mushroom::HitRight(int left, int right, int row)
- {
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(false);
- }
- #endif