-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlock.cpp
More file actions
66 lines (51 loc) · 998 Bytes
/
Block.cpp
File metadata and controls
66 lines (51 loc) · 998 Bytes
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
59
60
61
62
63
64
65
66
//
// Block.cpp
// PuzzleDora
//
// Created by otmb on 2014/09/20.
//
//
#include "Block.h"
USING_NS_CC;
//コンストラクタ
Block::Block()
: _state(State::Stop)
{
}
Block* Block::create()
{
auto node = new Block();
node->init();
node->autorelease();
return node;
}
bool Block::init()
{
if (!Sprite::initWithFile("ball.png")){
return false;
}
return true;
}
// ブロックの半径
void Block::setRadius()
{
_radius = getContentSize().width * getScale() * 0.5;
}
void Block::moveBlock(Vec2& pos)
{
_state = State::Moving;
auto move = MoveTo::create(0.2f, pos);
auto func = CallFunc::create([&]{
_state = State::Stop;
});
auto seq = Sequence::create(move,func,nullptr);
runAction(seq);
}
void Block::brokenBlock()
{
stopAllActions();
// 弾を消すアクションを起こす
Action* action = RemoveSelf::create();
runAction(action);
_state = State::Broken;
}