axmol/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h

48 lines
1.2 KiB
C++

//
// 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"
class PhysicsSprite : public cocos2d::CCSprite
{
public:
PhysicsSprite();
void setPhysicsBody(b2Body * body);
virtual bool isDirty(void);
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
private:
b2Body* m_pBody; // strong ref
};
class HelloWorld : public cocos2d::CCLayer {
public:
~HelloWorld();
HelloWorld();
// returns a Scene that contains the HelloWorld as the only child
static cocos2d::CCScene* scene();
void initPhysics();
// adds a new sprite at a given coordinate
void addNewSpriteAtPosition(cocos2d::CCPoint p);
virtual void draw();
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
void update(float dt);
private:
b2World* world;
cocos2d::CCTexture2D* m_pSpriteTexture; // weak ref
};
#endif // __HELLO_WORLD_H__