StaticCoin.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:2k
- //-------------------------------------------------------------------------------------
- //
- // This is part of MarioDemo, a platformer demo for JGE++
- //
- // Copyright (C) 2006 James Hui (a.k.a. Dr.Watson)
- //
- // This program is free software; you can redistribute it and/or modify it
- // under the terms of the GNU General Public License as published by the Free
- // Software Foundation; either version 2 of the License, or (at your option) any
- // later version.
- //
- // This program is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License along with
- // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- // Place, Suite 330, Boston, MA 02111-1307 USA
- //
- // Bugs and comments can be forwarded to jhkhui@yahoo.com.
- //
- //-------------------------------------------------------------------------------------
- #ifndef _STATIC_COIN_HPP_
- #define _STATIC_COIN_HPP_
- class Question: public GameObject
- {
- private:
- JSprite* question[10];
- int counter;
- int current;
- bool flag;
- public:
- Question(GameStatePlay* app);
- virtual ~Question();
- virtual void Update(float dt);
- virtual void Render();
- void setCurrent(int a);
- };
- Question::Question(GameStatePlay* app): GameObject(app)
- {
-
- for(int i = 0 ; i < 10 ; i++)
- {
- question[i] = new JSprite(mQuestion, i*160, 0.0f, 1600.0f, 100.0f);
- // mAnimatedCoin->AddFrame(129,97,30,30);
- // mAnimatedCoin->AddFrame(129,97,30,30,true);
- // mAnimatedCoin->AddFrame(97,97,30,30,true);
- //mAnimatedCoin->StartAnimation();
- question[i]->SetHotSpot(80*i, 50.0f);
- }
- flag = 0 ;
- //mAnimatedCoin->SetDuration(80);
-
- //mCurrAnimation = question;
- }
- Question::~Question()
- {
- for(int i = 0 ; i<10 ; i++)
- delete question[i];
- }
- void Question::Update(float dt)
- {
- if(counter < 30 )
- {
- counter++;
- flag = true;
- }
- else
- {
- counter=0;
- flag = 0 ;
- }
- }
- void Question::Render()
- {
- float x, y;
- mMap->GetPosition(&x, &y);
- if(flag)
- question[current]->AddFrame(mX-x-32, mY-y-64 , 160 , 100 );
-
- }
- void Question::setCurrent(int a )
- {
- current = a ;
-
- }
- #endif