BadFlower.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- #ifndef _BAD_FLOWER_HPP_
- #define _BAD_FLOWER_HPP_
- class BadFlower: public GameObject
- {
- private:
- JSprite* mFlower;
- float mUpperLimit;
- float mLowerLimit;
-
-
- public:
- BadFlower(GameStatePlay* app);
- virtual ~BadFlower();
- virtual void Update(float dt);
- virtual void Render();
- void Spawn(int col, int row);
- };
- BadFlower::BadFlower(GameStatePlay* app): GameObject(app)
- {
-
- mFlower = new JSprite(mTexture, 353, 97, 62, 74);
- mFlower->AddFrame(417,97,62,74);
- mFlower->SetHotSpot(31.0f, 74.0f);
- mFlower->SetDuration(200);
-
- mCurrAnimation = mFlower;
-
- mXVelocity = 0.0f;
- mYVelocity = 0.0f;
- }
- BadFlower::~BadFlower()
- {
-
- delete mFlower;
- }
- void BadFlower::Update(float dt)
- {
- mY += (mYVelocity*dt);
- if (mYVelocity < 0.0f)
- {
- if (mY < mUpperLimit)
- {
- mY = mUpperLimit;
- mYVelocity *= -1;
- }
- }
- else
- {
- if (mY > mLowerLimit)
- {
- mY = mLowerLimit;
- mYVelocity *= -1;
- }
- }
- mCurrAnimation->Update(dt);
- }
- void BadFlower::Render()
- {
- float x, y;
- mMap->GetPosition(&x, &y);
- //mCurrAnimation->SetColor(ARGB((int)mAlpha, 255, 255, 255));
-
- //mCurrAnimation->SetScale(0.8f, 0.8f);
- mCurrAnimation->SetPosition(mX-x, mY-y);
- //mEngine->EnableTextureFilter(false);
- mCurrAnimation->Render();
- //mEngine->EnableTextureFilter(true);
- }
- void BadFlower::Spawn(int col, int row)
- {
- mX = (float)(col<<TILE_SHIFT)+32.0f;
- mY = (float)((row+2)<<TILE_SHIFT);
-
- mLowerLimit = mY;
- mUpperLimit = mY - 128.0f;
- mYVelocity = -(BLOCK_SPEED/4);
- mCurrAnimation->StartAnimation();
-
- SetActive(true);
-
- }
- #endif