物理引擎Chipmunk--引力球

这篇博客介绍如何在Cocos2d-x中利用Chipmunk物理引擎创建一个带有引力效果的游戏场景。通过设置重力、碰撞形状、动态与静态物体以及应用力的方法,演示了如何让两个球体在屏幕中相互吸引并动态交互。
摘要由CSDN通过智能技术生成

//

//  PhysicsJoints2.hpp

//  day01

//

//  Created by MAC on 16/7/14.

//

//


#ifndef PhysicsJoints2_hpp

#define PhysicsJoints2_hpp



#include <stdio.h>

#include <iostream>

using namespace std;

#include "cocos2d.h"

using namespace cocos2d;

#include "ui/CocosGUI.h"

using namespace cocos2d::ui;


//const int DRAG_BODYS_TAG =1;

class PhysicsJoints2:public Layer{

public:

    static Scene* createScene();

    bool init();

    CREATE_FUNC(PhysicsJoints2);

    void onEnter();

    void onExit();

    PhysicsWorld* getPhysicsWorld();

    Sprite* makeBall(Vec2 point, float radius, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT);

private:

    Node * edgeShape;

    Size visiableSize;

    Vec2 center;

    PhysicsBody* _touchBody;

    DrawNode * draw;

};


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值