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"
|
|
|
|
|
2013-06-20 22:18:43 +08:00
|
|
|
class PhysicsSprite : public cocos2d::Sprite
|
2012-05-02 12:51:48 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PhysicsSprite();
|
|
|
|
void setPhysicsBody(b2Body * body);
|
|
|
|
virtual bool isDirty(void);
|
2013-06-20 22:18:43 +08:00
|
|
|
virtual cocos2d::AffineTransform nodeToParentTransform(void);
|
2012-05-02 12:51:48 +08:00
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
b2Body* _body; // strong ref
|
2012-05-02 12:51:48 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 22:18:43 +08:00
|
|
|
class HelloWorld : public cocos2d::Layer {
|
2011-06-13 20:35:39 +08:00
|
|
|
public:
|
|
|
|
~HelloWorld();
|
|
|
|
HelloWorld();
|
|
|
|
|
|
|
|
// returns a Scene that contains the HelloWorld as the only child
|
2013-06-20 22:18:43 +08:00
|
|
|
static cocos2d::Scene* scene();
|
2011-06-13 20:35:39 +08:00
|
|
|
|
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
|
2013-06-20 22:18:43 +08:00
|
|
|
void addNewSpriteAtPosition(cocos2d::Point p);
|
2012-05-02 12:51:48 +08:00
|
|
|
|
2011-06-13 20:35:39 +08:00
|
|
|
virtual void draw();
|
2013-06-20 22:18:43 +08:00
|
|
|
virtual void ccTouchesEnded(cocos2d::Set* touches, cocos2d::Event* event);
|
2012-06-22 12:00:27 +08:00
|
|
|
void update(float dt);
|
2011-06-13 20:35:39 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
b2World* world;
|
2013-06-20 22:18:43 +08:00
|
|
|
cocos2d::Texture2D* _spriteTexture; // weak ref
|
2011-06-13 20:35:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __HELLO_WORLD_H__
|