PuzzleSDK
MultiTouchTest类 参考

#include <MultiTouchTest.h>

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

Public 成员函数

 CREATE_FUNC (MultiTouchTest)
 
virtual bool init () override
 
void onTouchesBegan (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void onTouchesMoved (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void onTouchesEnded (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
void onTouchesCancelled (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 MultiTouchTest.h32 行定义.

成员函数说明

◆ CREATE_FUNC()

MultiTouchTest::CREATE_FUNC ( MultiTouchTest  )

◆ init()

bool MultiTouchTest::init ( )
overridevirtual

在文件 MultiTouchTest.cpp66 行定义.

67{
68 if (TestCase::init())
69 {
70 auto listener = EventListenerTouchAllAtOnce::create();
71 listener->onTouchesBegan = CC_CALLBACK_2(MultiTouchTest::onTouchesBegan, this);
72 listener->onTouchesMoved = CC_CALLBACK_2(MultiTouchTest::onTouchesMoved, this);
73 listener->onTouchesEnded = CC_CALLBACK_2(MultiTouchTest::onTouchesEnded, this);
74 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
75
76 auto title = Label::createWithSystemFont("Please touch the screen!", "", 24);
77 title->setPosition(VisibleRect::top()+Vec2(0.0f, -40.0f));
78 addChild(title);
79
80 return true;
81 }
82 return false;
83}
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
void onTouchesBegan(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
virtual std::string title() const
Definition: BaseTest.h:59
static cocos2d::Vec2 top()
Definition: VisibleRect.cpp:57

引用了 onTouchesBegan(), onTouchesEnded(), onTouchesMoved(), TestCase::title() , 以及 VisibleRect::top().

+ 函数调用图:

◆ onTouchesBegan()

void MultiTouchTest::onTouchesBegan ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 MultiTouchTest.cpp87 行定义.

88{
89 for ( auto &item: touches )
90 {
91 auto touch = item;
92 auto location = touch->getLocation();
93 auto touchPoint = TouchPoint::touchPointWithParent(this, location, *s_TouchColors[touch->getID()%5]);
94
95 addChild(touchPoint);
96 s_map.insert(touch->getID(), touchPoint);
97 }
98}
static Map< int, TouchPoint * > s_map
static const Color3B * s_TouchColors[5]
static TouchPoint * touchPointWithParent(Node *pParent, const Vec2 &touchPoint, const Color3B &touchColor)

引用了 s_map, s_TouchColors , 以及 TouchPoint::touchPointWithParent().

被这些函数引用 init().

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

◆ onTouchesCancelled()

void MultiTouchTest::onTouchesCancelled ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 MultiTouchTest.cpp128 行定义.

129{
130 onTouchesEnded(touches, event);
131}

引用了 onTouchesEnded().

+ 函数调用图:

◆ onTouchesEnded()

void MultiTouchTest::onTouchesEnded ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 MultiTouchTest.cpp117 行定义.

118{
119 for ( auto &item: touches )
120 {
121 auto touch = item;
122 auto pTP = s_map.at(touch->getID());
123 removeChild(pTP, true);
124 s_map.erase(touch->getID());
125 }
126}

引用了 s_map.

被这些函数引用 init() , 以及 onTouchesCancelled().

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

◆ onTouchesMoved()

void MultiTouchTest::onTouchesMoved ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 MultiTouchTest.cpp100 行定义.

101{
102 for( auto &item: touches)
103 {
104 auto touch = item;
105 auto pTP = s_map.at(touch->getID());
106 auto location = touch->getLocation();
107
108 removeChild(pTP, true);
109 s_map.erase(touch->getID());
110
111 auto touchPointNew = TouchPoint::touchPointWithParent(this, location, *s_TouchColors[touch->getID()%5]);
112 addChild(touchPointNew);
113 s_map.insert(touch->getID(), touchPointNew);
114 }
115}

引用了 s_map, s_TouchColors , 以及 TouchPoint::touchPointWithParent().

被这些函数引用 init().

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

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