4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cocos2d-xのPhysicsBodyを試してみる

Last updated at Posted at 2014-09-04

Cocos2dx 3.0 物理演算を試してみるを参考に下記を試してみた。
基本 cocos2d-x-3.2/tests/cpp-tests のコードベース

四角枠

GameScene.cpp
auto wall = Node::create();
    wall->setPhysicsBody(PhysicsBody::createEdgeBox(Size(winSize.width - 50,400), PhysicsMaterial(0.1f, 1.0f, 0.0f)));
    wall->setPosition(winSize.width / 2 + 3, 400);
    wall->setRotation(10.0f);
    addChild(wall);

四角枠.png

可変枠

GameScene.cpp
  Vec2 vec[5] =
    {
        Vec2(1, 300),
        Vec2(1, 100),
        Vec2(winSize.width/2, 0),
        Vec2(winSize.width-1,100),
        Vec2(winSize.width-1,300),
    };
    
    auto wall = Node::create();
    wall->setPhysicsBody(PhysicsBody::createEdgeChain(vec, 5, PhysicsMaterial(0.1f, 1.0f, 0.0f)));
    wall->setPosition(0, 0);
    addChild(wall);

可変枠.png

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?