39 auto s = getTexture()->getContentSize();
40 return Rect(-s.width / 2, -s.height / 2, s.width, s.height);
47 pPaddle->autorelease();
54 if( Sprite::initWithTexture(aTexture) )
67 auto listener = EventListenerTouchOneByOne::create();
68 listener->setSwallowTouches(
true);
74 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,
this);
86 return getRect().containsPoint(convertTouchToNodeSpaceAR(touch));
91 CCLOG(
"Paddle::onTouchBegan id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
110 CCLOG(
"Paddle::onTouchMoved id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
114 auto touchPoint = touch->getLocation();
116 setPosition( Vec2(touchPoint.x, getPosition().y) );
123 ret->setPosition(getPosition());
124 ret->setAnchorPoint(getAnchorPoint());
bool initWithTexture(cocos2d::Texture2D *aTexture) override
void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event)
bool containsTouchLocation(cocos2d::Touch *touch)
virtual void onEnter() override
virtual Paddle * clone() const override
void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event)
virtual void onExit() override
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
static Paddle * createWithTexture(cocos2d::Texture2D *aTexture)