我是 C++ 和 cocos2d-x 的新手,所以我不明白为什么会出错。代码
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类型作为参数,但它与位置 Header 失败:
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?