Turtle.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- #ifndef _TURTLE_HPP
- #define _TURTLE_HPP
- class Turtle: public MoveableObject
- {
- private:
-
-
- JSprite* mRun;
- JSprite* mDie;
- TileMap* mMap;
- int dead;
- u8 mTileInfo;
-
- public:
- Turtle(GameStatePlay* app);
- virtual ~Turtle();
- virtual void Update(float dt);
- virtual void HitLeft();
- virtual void HitRight(int left, int right, int row);
- void Spawn(int col, int row);
- void die();
- int aLive();
- };
- void Turtle::die()
- {
- mCurrAnimation = mDie;
- dead = 1 ;
- }
- int Turtle::aLive()
- {
- if(dead==0)
- return 1;
- else
- return 0;
- }
- Turtle::Turtle(GameStatePlay* app): MoveableObject(app)
- {
- mMap = mApp->GetTileMap();
- mRun = new JSprite(mTexture, 224, 96, 64, 64);//初始位子
- mRun->SetHotSpot(0.0f, 64.0f);
- mRun->AddFrame(288,96,64,64);//动作
- mRun->SetDuration(200.0f);
- mRun->StartAnimation();
- mDie = new JSprite(mTexture, 224, 96, 64, 64);
- mDie->SetHotSpot(0.0f, 77.0f);
- mDie->AddFrame(352,107,72,44);
- 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 ;
- }
- Turtle::~Turtle()
- {
- delete mDie;
- delete mRun;
- }
- void Turtle::Update(float dt)
- {
- if(dead)
- dead++;
- if(dead<250)
- MoveableObject::Update(dt);
- else
-
- mActive = false;
- }
- void Turtle::Spawn(int col, int row)
- {
- mX = (float)(col<<TILE_SHIFT);
- mY = (float)((row+1)<<TILE_SHIFT) - 1.0f;
- SetActive(true);
- }
- void Turtle::HitLeft()
- {
- mXVelocity = DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(true);
- }
- void Turtle::HitRight(int left, int right, int row)
- {
- mXVelocity = -DEFAULT_WALK_SPEED/2;
- mCurrAnimation->SetFlip(false);
- }
- #endif