2
我是C++新手和Cocos2d-X,所以我不明白爲什麼這是錯的。 代碼無法轉換「的cocos2d :: CCPoint」到「的cocos2d :: CCPoint」
void
MainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
// Get any touch and convert the touch position to in-game position.
CCTouch* touch = (CCTouch*)pTouches->anyObject();
CCPoint position = touch->locationInView();
position = CCDirector::sharedDirector()->convertToGL(position);
__pShip->setMove(position);
}
這是函數的代碼。
Ship::setMove(CCPoint *newPosition)
{
__move=*newPosition;
}
正如你可以看到它使用CCPoint類型作爲參數,但它失敗位置 標題:
class Ship : public AnimatedObject
{
public:
Ship();
bool init(const char* frameName, CCSpriteBatchNode* pSpriteSheet);
void setMove(CCPoint* newPosition);
void move();
private:
/**
* A CCMoveTo action set in the move() method.
*/
cocos2d::CCFiniteTimeAction* __pMoveAction;
/**
* This value specifies the ship's speed.
*/
float __speed;
/**
* This value specifies position to which the ship should move.
* It's set in touch events callbacks in MainLayer class.
*/
CCPoint __move;
};
我在做什麼錯?爲什麼這段代碼無法轉換CCPoints?
您能否提一下,錯誤的確切位置? – Ajay
__pShip-> setMove(position); – Sugar
指針或引用是不是很糟糕? – Sugar