-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBullet.cpp
More file actions
59 lines (46 loc) · 1.03 KB
/
Bullet.cpp
File metadata and controls
59 lines (46 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Bullet.cpp
// Puzzle2
//
// Created by otmb on 2014/09/05.
//
//
#include "Bullet.h"
USING_NS_CC;
//コンストラクタ
Bullet::Bullet()
: _state(State::Moving)
{
}
Bullet* Bullet::create()
{
auto node = new Bullet();
node->init();
node->autorelease();
return node;
}
bool Bullet::init()
{
if (!Sprite::initWithFile("ball.png")){
return false;
}
this->setScale(0.13f * bulletSize);
//this->setScale(0.043f * bulletSize);
auto pBall = PhysicsBody::createCircle(bulletSize,
PhysicsMaterial(1.0f, 0.6f, 0.3f));
pBall->setDynamic(true);
pBall->setRotationEnable(true);
pBall->setMoment(PHYSICS_INFINITY);
//log("%f",pBall->getMass());
pBall->setMass(1.0f);
this->setPhysicsBody(pBall);
return true;
}
void Bullet::brokenBullet()
{
stopAllActions();
// 弾を消すアクションを起こす
Action* action = RemoveSelf::create();
runAction(action);
_state = State::Broken;
}