2011-06-13 20:35:39 +08:00
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2012-05-02 14:06:12 +08:00
|
|
|
class ChipmunkPhysicsSprite : public cocos2d::CCSprite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ChipmunkPhysicsSprite();
|
|
|
|
virtual ~ChipmunkPhysicsSprite();
|
|
|
|
void setPhysicsBody(cpBody* body);
|
|
|
|
virtual bool isDirty(void);
|
|
|
|
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
cpBody* _body; // strong ref
|
2012-05-02 14:06:12 +08:00
|
|
|
};
|
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
// HelloWorld Layer
|
|
|
|
class HelloWorld : public cocos2d::CCLayer {
|
|
|
|
public:
|
2012-05-02 14:06:12 +08:00
|
|
|
HelloWorld();
|
|
|
|
~HelloWorld();
|
2012-05-02 14:17:14 +08:00
|
|
|
bool init();
|
2012-05-02 14:06:12 +08:00
|
|
|
static cocos2d::CCScene* scene();
|
2012-08-29 21:03:47 +08:00
|
|
|
CREATE_FUNC(HelloWorld);
|
2011-06-13 20:35:39 +08:00
|
|
|
|
2012-05-02 14:06:12 +08:00
|
|
|
void initPhysics();
|
2012-05-02 14:17:14 +08:00
|
|
|
void addNewSpriteAtPosition(cocos2d::CCPoint p);
|
2012-06-22 12:00:27 +08:00
|
|
|
void update(float dt);
|
2012-05-02 14:17:14 +08:00
|
|
|
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
|
|
|
|
virtual void didAccelerate(cocos2d::CCAcceleration* pAccelerationValue);
|
2012-05-02 14:06:12 +08:00
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
cocos2d::CCTexture2D* _spriteTexture; // weak ref
|
|
|
|
cpSpace* _space; // strong ref
|
|
|
|
cpShape* _walls[4];
|
2012-05-02 14:06:12 +08:00
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __HELLOW_WORLD_H__
|