//必须 要有float类型的参数
void MainScene::updateFrame(float dt)
{
if (spriteTest != NULL && spriteTest->getBoundingBox().intersectsRect(sprite->getBoundingBox())) {
CCLOG("碰撞了!");
spriteTest->stopAllActions();
spriteTest->removeFromParentAndCleanup(true);
spriteTest = NULL;
}
}
bool MainScene::init()
{
if (!Layer::init()) {
return false; } //创建一个精灵
spriteTest = Sprite::create("1.png");
spriteTest->setPosition(Point(,));
this->addChild(spriteTest); sprite = Sprite::create("1.png");
sprite->setPosition(Point(,));
this->addChild(sprite); MoveBy *by = MoveBy::create(, Vec2(, ));
spriteTest->runAction(by); //帧回调
this->schedule(schedule_selector(MainScene::updateFrame));
return true; }