PuzzleSDK
Paddle类 参考

#include <Paddle.h>

+ 类 Paddle 继承关系图:
+ Paddle 的协作图:

Public 成员函数

 Paddle ()
 
virtual ~Paddle ()
 
cocos2d::Rect getRect ()
 
bool initWithTexture (cocos2d::Texture2D *aTexture) override
 
virtual void onEnter () override
 
virtual void onExit () override
 
bool containsTouchLocation (cocos2d::Touch *touch)
 
bool onTouchBegan (cocos2d::Touch *touch, cocos2d::Event *event)
 
void onTouchMoved (cocos2d::Touch *touch, cocos2d::Event *event)
 
void onTouchEnded (cocos2d::Touch *touch, cocos2d::Event *event)
 
virtual Paddleclone () const override
 

静态 Public 成员函数

static PaddlecreateWithTexture (cocos2d::Texture2D *aTexture)
 

Private 属性

PaddleState _state
 

详细描述

在文件 Paddle.h37 行定义.

构造及析构函数说明

◆ Paddle()

Paddle::Paddle ( )

在文件 Paddle.cpp29 行定义.

30{
31}

被这些函数引用 createWithTexture().

+ 这是这个函数的调用关系图:

◆ ~Paddle()

Paddle::~Paddle ( )
virtual

在文件 Paddle.cpp33 行定义.

34{
35}

成员函数说明

◆ clone()

Paddle * Paddle::clone ( ) const
overridevirtual

在文件 Paddle.cpp119 行定义.

120{
121 Paddle* ret = Paddle::createWithTexture(_texture);
122 ret->_state = _state;
123 ret->setPosition(getPosition());
124 ret->setAnchorPoint(getAnchorPoint());
125 return ret;
126}
Definition: Paddle.h:38
PaddleState _state
Definition: Paddle.h:39
static Paddle * createWithTexture(cocos2d::Texture2D *aTexture)
Definition: Paddle.cpp:43

引用了 _state , 以及 createWithTexture().

+ 函数调用图:

◆ containsTouchLocation()

bool Paddle::containsTouchLocation ( cocos2d::Touch *  touch)

在文件 Paddle.cpp84 行定义.

85{
86 return getRect().containsPoint(convertTouchToNodeSpaceAR(touch));
87}
cocos2d::Rect getRect()
Definition: Paddle.cpp:37

引用了 getRect().

被这些函数引用 onTouchBegan().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ createWithTexture()

Paddle * Paddle::createWithTexture ( cocos2d::Texture2D *  aTexture)
static

在文件 Paddle.cpp43 行定义.

44{
45 Paddle* pPaddle = new (std::nothrow) Paddle();
46 pPaddle->initWithTexture(aTexture);
47 pPaddle->autorelease();
48
49 return pPaddle;
50}
bool initWithTexture(cocos2d::Texture2D *aTexture) override
Definition: Paddle.cpp:52
Paddle()
Definition: Paddle.cpp:29

引用了 initWithTexture() , 以及 Paddle().

被这些函数引用 clone() , 以及 PongLayer::PongLayer().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ getRect()

Rect Paddle::getRect ( )

在文件 Paddle.cpp37 行定义.

38{
39 auto s = getTexture()->getContentSize();
40 return Rect(-s.width / 2, -s.height / 2, s.width, s.height);
41}

被这些函数引用 Ball::collideWithPaddle() , 以及 containsTouchLocation().

+ 这是这个函数的调用关系图:

◆ initWithTexture()

bool Paddle::initWithTexture ( cocos2d::Texture2D *  aTexture)
override

在文件 Paddle.cpp52 行定义.

53{
54 if( Sprite::initWithTexture(aTexture) )
55 {
57 }
58
59 return true;
60}
@ kPaddleStateUngrabbed
Definition: Paddle.h:34

引用了 _state , 以及 kPaddleStateUngrabbed.

被这些函数引用 createWithTexture().

+ 这是这个函数的调用关系图:

◆ onEnter()

void Paddle::onEnter ( )
overridevirtual

在文件 Paddle.cpp62 行定义.

63{
64 Sprite::onEnter();
65
66 // Register Touch Event
67 auto listener = EventListenerTouchOneByOne::create();
68 listener->setSwallowTouches(true);
69
70 listener->onTouchBegan = CC_CALLBACK_2(Paddle::onTouchBegan, this);
71 listener->onTouchMoved = CC_CALLBACK_2(Paddle::onTouchMoved, this);
72 listener->onTouchEnded = CC_CALLBACK_2(Paddle::onTouchEnded, this);
73
74 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
75}
void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event)
Definition: Paddle.cpp:128
void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)
Definition: Paddle.cpp:101
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
Definition: Paddle.cpp:89

引用了 onTouchBegan(), onTouchEnded() , 以及 onTouchMoved().

+ 函数调用图:

◆ onExit()

void Paddle::onExit ( )
overridevirtual

在文件 Paddle.cpp77 行定义.

78{
79// auto director = Director::getInstance();
80// director->getTouchDispatcher()->removeDelegate(this);
81 Sprite::onExit();
82}

◆ onTouchBegan()

bool Paddle::onTouchBegan ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 Paddle.cpp89 行定义.

90{
91 CCLOG("Paddle::onTouchBegan id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
92
93 if (_state != kPaddleStateUngrabbed) return false;
94 if ( !containsTouchLocation(touch) ) return false;
95
97 CCLOG("return true");
98 return true;
99}
@ kPaddleStateGrabbed
Definition: Paddle.h:33
bool containsTouchLocation(cocos2d::Touch *touch)
Definition: Paddle.cpp:84

引用了 _state, containsTouchLocation(), kPaddleStateGrabbed , 以及 kPaddleStateUngrabbed.

被这些函数引用 onEnter().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ onTouchEnded()

void Paddle::onTouchEnded ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 Paddle.cpp128 行定义.

129{
130 CCASSERT(_state == kPaddleStateGrabbed, "Paddle - Unexpected state!");
131
133}

引用了 _state, kPaddleStateGrabbed , 以及 kPaddleStateUngrabbed.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

◆ onTouchMoved()

void Paddle::onTouchMoved ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 Paddle.cpp101 行定义.

102{
103 // If it weren't for the TouchDispatcher, you would need to keep a reference
104 // to the touch from touchBegan and check that the current touch is the same
105 // as that one.
106 // Actually, it would be even more complicated since in the Cocos dispatcher
107 // you get Sets instead of 1 UITouch, so you'd need to loop through the set
108 // in each touchXXX method.
109
110 CCLOG("Paddle::onTouchMoved id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
111
112 CCASSERT(_state == kPaddleStateGrabbed, "Paddle - Unexpected state!");
113
114 auto touchPoint = touch->getLocation();
115
116 setPosition( Vec2(touchPoint.x, getPosition().y) );
117}

引用了 _state , 以及 kPaddleStateGrabbed.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _state

PaddleState Paddle::_state
private

在文件 Paddle.h39 行定义.

被这些函数引用 clone(), initWithTexture(), onTouchBegan(), onTouchEnded() , 以及 onTouchMoved().


该类的文档由以下文件生成: