本文整理汇总了C++中Fish::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Fish::getContentSize方法的具体用法?C++ Fish::getContentSize怎么用?C++ Fish::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fish
的用法示例。
在下文中一共展示了Fish::getContentSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkCollision
void GameScene::checkCollision(){
std::vector<int> catched;
for (int i = 0; i < _fish.size(); i++) {
Fish *fish = _fish.at(i);
if (!fish->getIsCatched()) {
Point fishPoint = fish->getPosition();
Size fishSize = Size(fish->getContentSize().width * fabs(fish->getScaleX()), fish->getContentSize().height * fabs(fish->getScaleY()));
Point hookpoint = _fisherman->getHookWorldPoint();
bool x = false;
bool y = false;
if (((fishPoint.x - (fishSize.width/2)) < hookpoint.x) &&
((fishPoint.x + (fishSize.width/2)) > hookpoint.x)) {
x = true;
}
if (((fishPoint.y - (fishSize.height/2)) < hookpoint.y) &&
((fishPoint.y + (fishSize.height/2)) > hookpoint.y)) {
y = true;
}
if (x && y) {
catched.push_back(i);
}
}
}
for (int i = 0; i < catched.size(); i++) {
int x = catched.at(i);
Fish *f = _fish.at(x);
if(f != _catchedFish) {
f->setIsCatched(true);
if (!_catchedFish) {
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("new_pick_up.wav");
_catchedFish = f;
_catchedFish->setPreventAnimations(true);
_catchedFish->setRotation(_catchedFish->getScaleX() > 0 ? 90 : 270);
_scoreMultiplier = 1;
_currentScore = _catchedFish->getScore();
} else {
if (!dynamic_cast<Turtle*>(f)) {
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("new_pick_up.wav");
_scoreMultiplier ++;
if (f->getScore() > _catchedFish->getScore()) {
// f->setScore(f->getScore());
_fish.erase(std::remove(_fish.begin(), _fish.end(), _catchedFish), _fish.end());
_catchedFish->removeFromParent();
_catchedFish = NULL;
_catchedFish = f;
_currentScore += _catchedFish->getScore();
_catchedFish->setPreventAnimations(true);
_catchedFish->setRotation(_catchedFish->getScaleX() > 0 ? 90 : 270);
} else {
_currentScore += f->getScore();
_fish.erase(std::remove(_fish.begin(), _fish.end(), f), _fish.end());
f->removeFromParent();
f = NULL;
}
}
}
}
}
if (_currentScore > 0) {
char buff[100];
sprintf(buff, "%dX%i", (int)roundf(_currentScore),(int)_scoreMultiplier);
std::string buffAsStdStr = buff;
_currentLabel->setString(buffAsStdStr);
}
}