29MultiTouchTests::MultiTouchTests()
45 TouchPoint(
const Vec2 &touchPoint,
const Color3B &touchColor)
47 DrawNode* drawNode = DrawNode::create();
48 auto s = Director::getInstance()->getWinSize();
49 Color4F color(touchColor.r/255.0f, touchColor.g/255.0f, touchColor.b/255.0f, 1.0f);
50 drawNode->drawLine(Vec2(0.0f, touchPoint.y), Vec2(s.width, touchPoint.y), color);
51 drawNode->drawLine(Vec2(touchPoint.x, 0.0f), Vec2(touchPoint.x, s.height), color);
52 drawNode->drawDot(touchPoint, 3, color);
58 auto pRet =
new (std::nothrow)
TouchPoint(touchPoint, touchColor);
59 pRet->setContentSize(pParent->getContentSize());
60 pRet->setAnchorPoint(Vec2(0.0f, 0.0f));
70 auto listener = EventListenerTouchAllAtOnce::create();
74 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,
this);
76 auto title = Label::createWithSystemFont(
"Please touch the screen!",
"", 24);
85static Map<int, TouchPoint*>
s_map;
89 for (
auto &item: touches )
92 auto location = touch->getLocation();
96 s_map.insert(touch->getID(), touchPoint);
102 for(
auto &item: touches)
105 auto pTP =
s_map.at(touch->getID());
106 auto location = touch->getLocation();
108 removeChild(pTP,
true);
109 s_map.erase(touch->getID());
112 addChild(touchPointNew);
113 s_map.insert(touch->getID(), touchPointNew);
119 for (
auto &item: touches )
122 auto pTP =
s_map.at(touch->getID());
123 removeChild(pTP,
true);
124 s_map.erase(touch->getID());
#define ADD_TEST_CASE(__className__)
static Map< int, TouchPoint * > s_map
static const Color3B * s_TouchColors[5]
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
void onTouchesCancelled(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 bool init() override
virtual std::string title() const
static TouchPoint * touchPointWithParent(Node *pParent, const Vec2 &touchPoint, const Color3B &touchColor)
TouchPoint(const Vec2 &touchPoint, const Color3B &touchColor)
static cocos2d::Vec2 top()