Merge pull request #836 from minggo/touch_case

fix TouchesTest crashed on Android and iOS
This commit is contained in:
minggo 2012-04-12 18:47:41 -07:00
commit 7cf16dbb32
4 changed files with 25 additions and 20 deletions

View File

@ -8,4 +8,4 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-9 target=android-10

View File

@ -78,6 +78,12 @@ void Paddle::ccTouchMoved(CCTouch* touch, CCEvent* event)
setPosition( CCPointMake(touchPoint.x, getPosition().y) ); setPosition( CCPointMake(touchPoint.x, getPosition().y) );
} }
CCObject* Paddle::copyWithZone(CCZone *pZone)
{
this->retain();
return this;
}
void Paddle::ccTouchEnded(CCTouch* touch, CCEvent* event) void Paddle::ccTouchEnded(CCTouch* touch, CCEvent* event)
{ {
CCAssert(m_state == kPaddleStateGrabbed, L"Paddle - Unexpected state!"); CCAssert(m_state == kPaddleStateGrabbed, L"Paddle - Unexpected state!");

View File

@ -1,14 +1,14 @@
#ifndef _PADDLE_H_ #ifndef _PADDLE_H_
#define _PADDLE_H_ #define _PADDLE_H_
#include "cocos2d.h" #include "cocos2d.h"
using namespace cocos2d; using namespace cocos2d;
typedef enum tagPaddleState typedef enum tagPaddleState
{ {
kPaddleStateGrabbed, kPaddleStateGrabbed,
kPaddleStateUngrabbed kPaddleStateUngrabbed
} PaddleState; } PaddleState;
class Paddle : public CCSprite, public CCTargetedTouchDelegate class Paddle : public CCSprite, public CCTargetedTouchDelegate
@ -20,18 +20,19 @@ public:
virtual ~Paddle(void); virtual ~Paddle(void);
CCRect rect(); CCRect rect();
bool initWithTexture(CCTexture2D* aTexture); bool initWithTexture(CCTexture2D* aTexture);
virtual void onEnter(); virtual void onEnter();
virtual void onExit(); virtual void onExit();
bool containsTouchLocation(CCTouch* touch); bool containsTouchLocation(CCTouch* touch);
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event); virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event);
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); virtual void ccTouchMoved(CCTouch* touch, CCEvent* event);
virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); virtual void ccTouchEnded(CCTouch* touch, CCEvent* event);
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void touchDelegateRetain();
virtual void touchDelegateRelease();
static Paddle* paddleWithTexture(CCTexture2D* aTexture); virtual void touchDelegateRetain();
virtual void touchDelegateRelease();
static Paddle* paddleWithTexture(CCTexture2D* aTexture);
}; };
#endif #endif

View File

@ -24,7 +24,6 @@ enum
// //
//------------------------------------------------------------------ //------------------------------------------------------------------
PongScene::PongScene() PongScene::PongScene()
:TestScene(true)
{ {
PongLayer *pongLayer = new PongLayer();//PongLayer::node(); PongLayer *pongLayer = new PongLayer();//PongLayer::node();
addChild(pongLayer); addChild(pongLayer);
@ -33,7 +32,6 @@ PongScene::PongScene()
void PongScene::MainMenuCallback(CCObject* pSender) void PongScene::MainMenuCallback(CCObject* pSender)
{ {
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
TestScene::MainMenuCallback(pSender); TestScene::MainMenuCallback(pSender);
} }