2011-06-13 20:35:39 +08:00
|
|
|
//
|
|
|
|
// HelloWorldScene.h
|
|
|
|
// ___PROJECTNAME___
|
|
|
|
//
|
|
|
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
|
|
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
|
|
|
//
|
|
|
|
#ifndef __HELLO_WORLD_H__
|
|
|
|
#define __HELLO_WORLD_H__
|
|
|
|
|
|
|
|
// When you import this file, you import all the cocos2d classes
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "Box2D.h"
|
|
|
|
|
2012-05-02 13:03:47 +08:00
|
|
|
class PhysicsSprite : public cocos2d::CCSprite
|
2012-05-02 12:51:48 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PhysicsSprite();
|
|
|
|
void setPhysicsBody(b2Body * body);
|
|
|
|
virtual bool isDirty(void);
|
2012-05-02 13:03:47 +08:00
|
|
|
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
|
2012-05-02 12:51:48 +08:00
|
|
|
private:
|
|
|
|
b2Body* m_pBody; // strong ref
|
|
|
|
};
|
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
class HelloWorld : public cocos2d::CCLayer {
|
|
|
|
public:
|
|
|
|
~HelloWorld();
|
|
|
|
HelloWorld();
|
|
|
|
|
|
|
|
// returns a Scene that contains the HelloWorld as the only child
|
|
|
|
static cocos2d::CCScene* scene();
|
|
|
|
|
2012-05-02 12:51:48 +08:00
|
|
|
void initPhysics();
|
2011-06-13 20:35:39 +08:00
|
|
|
// adds a new sprite at a given coordinate
|
2012-05-02 13:03:47 +08:00
|
|
|
void addNewSpriteAtPosition(cocos2d::CCPoint p);
|
2012-05-02 12:51:48 +08:00
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
virtual void draw();
|
|
|
|
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
|
2012-06-22 12:00:27 +08:00
|
|
|
void update(float dt);
|
2011-06-13 20:35:39 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
b2World* world;
|
2012-05-02 13:03:47 +08:00
|
|
|
cocos2d::CCTexture2D* m_pSpriteTexture; // weak ref
|
2011-06-13 20:35:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __HELLO_WORLD_H__
|