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

52 lines
1.2 KiB
C
Raw Normal View History

//
// HelloWorldScene.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef __HELLOW_WORLD_H__
#define __HELLOW_WORLD_H__
#include "cocos2d.h"
// include Chipmunk headers
#include "chipmunk.h"
class ChipmunkPhysicsSprite : public cocos2d::CCSprite
{
public:
ChipmunkPhysicsSprite();
virtual ~ChipmunkPhysicsSprite();
void setPhysicsBody(cpBody* body);
virtual bool isDirty(void);
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
private:
cpBody* _body; // strong ref
};
// HelloWorld Layer
class HelloWorld : public cocos2d::CCLayer {
public:
HelloWorld();
~HelloWorld();
bool init();
static cocos2d::CCScene* scene();
CREATE_FUNC(HelloWorld);
void initPhysics();
void addNewSpriteAtPosition(cocos2d::CCPoint p);
void update(float dt);
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void didAccelerate(cocos2d::CCAcceleration* pAccelerationValue);
private:
cocos2d::CCTexture2D* _spriteTexture; // weak ref
cpSpace* _space; // strong ref
cpShape* _walls[4];
};
#endif // __HELLOW_WORLD_H__