本文整理汇总了C++中getSprite函数的典型用法代码示例。如果您正苦于以下问题:C++ getSprite函数的具体用法?C++ getSprite怎么用?C++ getSprite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSprite函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ballInRightHole
void BaseScene::ballInRightHole(){
if (SceneDesigner::balls == nullptr || SceneDesigner::holes == nullptr) return;
std::vector<int> removeballindex;
std::vector<int> removeholeindex;
for (int i = 0; i < int(SceneDesigner::balls->size()); i++){
auto ball = SceneDesigner::balls->at(i);
for (int j = 0; j < int(SceneDesigner::holes->size()); j++){
auto hole = SceneDesigner::holes->at(j);
// 球进洞了
if (ball->getSprite()->getPosition().distance(hole->sprite->getPosition()) < (hole->holesize - ball->radius / 3 * 2) ||
ball->getSprite()->getPosition().distance(hole->sprite->getPosition()) < hole->holesize / 2){
if (int(ball->type) == int(hole->type) // 进对洞了
|| hole->type == HoleType::h_blackhole_small || hole->type == HoleType::h_blackhole_mid // 黑洞
|| ball->type == BallType::b_doubleball_mid || ball->type == BallType::b_doubleball_small // 双面球
){
addScore(500, hole->sprite->getPosition());
removeballindex.push_back(i);
removeholeindex.push_back(j);
}
else if (ball->type == BallType::b_eggball_mid || ball->type == BallType::b_eggball_small){ // eggBall 进错洞了,也有200分
addScore(200, hole->sprite->getPosition());
removeballindex.push_back(i);
removeholeindex.push_back(j);
}
}
}
}
SceneDesigner::removeBallAndHole(removeballindex, removeholeindex);
}
开发者ID:yinglang,项目名称:DemoWork,代码行数:33,代码来源:BaseScene.cpp
示例2: GObject
GEBackground::GEBackground(int x, int y,std::string spriteloc) : GObject(x,y,0,0,true)
{
this->setSprite(spriteloc);
setW(getSprite()->w);
setH(getSprite()->h);
}
开发者ID:fenexomega,项目名称:gof,代码行数:7,代码来源:GEBackground.cpp
示例3: formatStr
void MainLayer::createSpecRecomend()
{
if (!_hideNode->isVisible() || _pageView->getCurPageIndex() != MAIN_PAGE || !_isUseSpec)
return;
auto rt = RenderTexture::create(_pageView->getContentSize().width,
_pageView->getContentSize().height,
Texture2D::PixelFormat::RGBA8888,
GL_DEPTH24_STENCIL8);
rt->beginWithClear(0, 0, 0, 0, 0);
_pageView->getPage(MAIN_PAGE)->visit(_director->getRenderer(), _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW), true);
rt->end();
rt->getSprite()->setScaleY(-1);
auto sprite = dynamic_cast<Sprite*>(LsTools::seekNodeByName(_rootNode, formatStr("dy_%d", MAIN_PAGE)));
sprite->setTexture(rt->getSprite()->getTexture());
auto pane1 = LsTools::seekNodeByName(_pageView, "Panel_0");
auto img3 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "3"));
auto img0 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "0"));
auto img2 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "2"));
auto img1 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "1"));
Rect rect(img1->getLeftBoundary(), img1->getBottomBoundary(),
img3->getRightBoundary() - img1->getLeftBoundary(),
img2->getContentSize().height);
sprite->setTextureRect(Rect(rect.origin.x, rect.origin.y, rect.size.width, 300));
float bot = img2->getBottomBoundary() - (sprite->getTextureRect().getMaxY() - sprite->getTextureRect().getMinY()) / 2 - 5;
}
开发者ID:sharezer,项目名称:xZone,代码行数:30,代码来源:MainLayer.cpp
示例4: init
bool GameView::init()
{
auto bg = Sprite::create("assets/323.jpg");
this->addChild(bg);
auto size = Director::getInstance()->getWinSize();
bg->setPosition(size.width/2, size.height/2);
GetCommponent<GameModel*>("GameModel")->registerEvent(GameModel::EVENT_EXCHANGE, [=](const Msg &msg){
for (int i=0; i<xCount; i++) {
for (int j=0; j<yCount; j++) {
auto fruit = GetCommponent<GameModel*>("GameModel")->getFuit(i, j);
if (fruit) {
auto sp = fruit->getSprite();
sp->setPosition(getFruitPosition(i,j));
}
}
}
});
for (int i=0; i<xCount; i++) {
for (int j=0; j<yCount; j++) {
auto fruit = GetCommponent<GameModel*>("GameModel")->getFuit(i, j);
if (fruit) {
auto sp = fruit->getSprite();
this->addChild(sp);
sp->setPosition(getFruitPosition(i,j));
}
}
}
return true;
}
开发者ID:nimabi8984,项目名称:Threes,代码行数:30,代码来源:GameView.cpp
示例5: _velocity
PlayerSprite::PlayerSprite() : _velocity(0.0f), _maxVelocity(.3f), _acceleration(.0005f), _jumping(false), _velY(0.0f)
{
load("images/PlayerPrototype.png");
assert(isLoaded());
getSprite().setOrigin(getSprite().getScale().x / 2, getSprite().getScale().y / 2);
}
开发者ID:GIumbatsch,项目名称:lootenUndLeveln,代码行数:7,代码来源:PlayerSprite.cpp
示例6: getSprite
void Button::setRessource(Ressource* res,bool setSprite){
this->ressource = res;
if(setSprite){
this->ressource->getSprite()->setPosition(getSprite()->getPosition().x, getSprite()->getPosition().y);
}
}
开发者ID:legionth,项目名称:Survival,代码行数:7,代码来源:Button.cpp
示例7: unscheduleAllSelectors
void Carrot::CarrotBeHurt(Ref * pRef)
{
SoundUtil::getInstance()->playEffect(CARROTCRASH);
MonsterBase * pMonster = (MonsterBase *)pRef;
iHp -= pMonster->getIAtk();
if (iHp <= 0)
{
GameManager::getInstance()->setICarrotHp(0);
auto tGameEndType = en_GameLose;
NOTIFY->postNotification("gameEnd", reinterpret_cast<Ref*>(&tGameEndType));
NOTIFY->removeAllObservers(this);
return;
}
GameManager::getInstance()->setICarrotHp(iHp);
Director::getInstance()->getEventDispatcher()->removeEventListenersForTarget(getSprite());
unscheduleAllSelectors();
_HpSprite->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(StringUtils::format("BossHP%02d.png",iHp)));
std::string HurtSpriteName;
if (iHp == 5 || iHp == 7)
{
HurtSpriteName = StringUtils::format("hlb%d.png", iHp + 1);
}
else
{
HurtSpriteName = StringUtils::format("hlb%d.png", iHp);
}
getSprite()->stopAllActions();
getSprite()->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(HurtSpriteName));
}
开发者ID:joyfish,项目名称:TowerTD,代码行数:29,代码来源:Carrot.cpp
示例8: getSprite
////////////////////////////////////////////////////////////////////////////////
// CTOR / DTOR //
////////////////////////////////////////////////////////////////////////////////
BonusEnemy::BonusEnemy()
{
//Sprite / Frames
auto &sprite = getSprite();
sprite.loadTexture("Images/bonus_sprites.png");
auto spriteRect = getSprite().getBounds();
m_spriteSize.x = spriteRect.getWidth () / kFramesCount;
m_spriteSize.y = spriteRect.getHeight ();
//Timers
auto appearTick = COREGAME_CALLBACK_0(BonusEnemy::onAppearTimerTick, this);
auto stayTick = COREGAME_CALLBACK_0(BonusEnemy::onStayTimerTick, this);
m_appearTimer.setTickCallback(appearTick);
m_stayTimer.setTickCallback (stayTick);
m_appearTimer.setRepeatCount(kRepeatCount_OneTime);
m_stayTimer.setRepeatCount (kRepeatCount_OneTime);
//Init type.
setType(BonusEnemy::Type::None);
resetAppearTimer();
}
开发者ID:AmazingCow-Game,项目名称:Game_Frogger,代码行数:29,代码来源:BonusEnemy.cpp
示例9: registerInterest
Trap::Trap(int x, int y)
{
LogManager &log_manager = LogManager::getInstance();
#ifdef REGISTER
// Need to update fire rate control each step.
registerInterest(DF_STEP_EVENT);
#endif
// Set object type.
setType("Trap");
auto& resMgr = ResourceManager::getInstance();
setSprite(resMgr.getSprite("trap"));
setSpriteSlowdown(4);
setAltitude(1);
// Set starting location.
WorldManager &world_manager = WorldManager::getInstance();
Position pos(7, world_manager.getBoundary().getVertical() / 2);
setPosition(Position(x, y));
setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight()));
//setYVelocity(0.25);
// Set firing variables.
}
开发者ID:piaoasd123,项目名称:IMGD3000PROJ2,代码行数:26,代码来源:Trap.cpp
示例10: CCRectMake
CCRect Entity::boundingBox() {
if(getSprite() == NULL) {
return CCRectMake(0, 0, 0, 0);
}
CCPoint pos = getPosition();
CCSize size = getSprite()->getContentSize();
return CCRectMake(pos.x, pos.y, size.width, size.height);
}
开发者ID:ruozigongzuoshi,项目名称:goddessemblem,代码行数:9,代码来源:Entity.cpp
示例11: ASSERT
/**
* Configures some properties of the specified layer to make it as the
* "Background" of the sprite.
*
* You can't use this routine if the sprite already has a background
* layer.
*/
void LayerImage::configureAsBackground()
{
ASSERT(getSprite() != NULL);
ASSERT(getSprite()->getBackgroundLayer() == NULL);
setMoveable(false);
setBackground(true);
setName("Background");
getSprite()->getFolder()->stackLayer(this, NULL);
}
开发者ID:bradparks,项目名称:aseprite,代码行数:18,代码来源:layer.cpp
示例12: getSprite
void Missile::explode() {
state = Missile::sExploding;
current_animation_ = resources_.explosion_anim_;
getSprite(sprMissile).setTextureCoords(current_animation_.getRegion().getTextureRect());
transform.setPosition(transform.getPosition() + speed.getLinearSpeed()/10); // explode a little further than impacted
transform.setRotation(0);
transform.setScale({1, 1});
speed.setLinearSpeed({0, 0});
speed.setAngularSpeed(0);
getSprite(sprMissile).setSize({50, 50});
}
开发者ID:grynca,项目名称:LD33,代码行数:11,代码来源:Missile.cpp
示例13: Bullet
float EnemyForwardAttack::fire()
{
Level::spawnBullet(new Bullet("bullet_simple.png",
1, 1,
getSprite().getPosition().x,
getSprite().getPosition().y,
180.0f,
1.0f),
sf::Vector2f(500.0f, 0.0f),
false);
return 0.5;
}
开发者ID:LCClyde,项目名称:Nyra,代码行数:12,代码来源:EnemyForwardAttack.cpp
示例14: getHeight
void Stickman::render(QPainter &painter) const
{
// Draw the stickman at the bottom of the screen
int yPos = painter.device()->height() - getHeight();
// Find how much to scale the sprite image by to match the bounding box of the stickman
// If x velocity is negative, we flip the image as well.
float scaleX = getWidth() / getSprite().width() * (m_xVelocity < 0 ? -1 : 1);
float scaleY = getHeight() / getSprite().height();
painter.drawPixmap(m_xOffset, yPos, getSprite().transformed(QTransform().scale(scaleX, scaleY)));
}
开发者ID:jyting,项目名称:superstickmanpt3,代码行数:12,代码来源:stickman.cpp
示例15: velocity
PlayerObject::PlayerObject(std::string Pname) :
velocity(0.0f),
playerName(Pname),
maxVelocity(800.0f),
rotRate(0.0f),
SpeedRate(7.0f),
RUN_YET(false)
{
load("sprites/android.png");
getSprite().setOrigin(getSprite().getLocalBounds().width / 2, getSprite().getLocalBounds().height / 2); // Sets the playerObjects origin to the center of the sprite
}
开发者ID:Tumppinator,项目名称:AppleDodger,代码行数:12,代码来源:PlayerObject.cpp
示例16: getSprite
void AlchemyMenu::addButton(AlchemyButton* button){
buttons.push_back(button);
int count = buttons.size();
int posX = getSprite()->getPosition().x;
int posY = getSprite()->getPosition().y;
if(count == 1){
button->getSprite()->setPosition((posX*count),posY);
}else{
button->getSprite()->setPosition((posX)+ (BUTTON_WIDTH*(count - 1)),posY); //Put in line
}
//std::cout<<"(posX*count)+BUTTON_WIDTH"<<(posX)+ (BUTTON_WIDTH*count)<<std::endl;
}
开发者ID:legionth,项目名称:Survival,代码行数:14,代码来源:AlchemyMenu.cpp
示例17: jump
void Player::jump() {
if (getSprite() == NULL || m_isJumping || Config::isPause) {
return;
}
auto size = Director::getInstance()->getVisibleSize();
if (size.width / 2 - this->radius < 10) {
return;
}
m_isJumping = true;
this->size = 0.15;
float xdiff = this->currentPos.x > 0 ? 1 : -1;
float ydiff = this->currentPos.y > 0 ? 1 : -1;
auto jump = JumpBy::create(0.2f, Point(xdiff * size.width / 11, ydiff * size.width / 11), size.width / 10, 1);
auto scale = ScaleTo::create(0.2f, this->size);
auto callFunc = CallFunc::create([&](){
auto vs = Director::getInstance()->getVisibleSize();
this->currentPos = Point(this->getPosition().x - vs.width / 2, this->getPosition().y - vs.width / 2);
this->radius += vs.width / 11;
this->maxRadius = this->maxRadius > this->radius ? this->maxRadius : this->radius;
this->setScale(0.1);
m_isJumping = false;
});
auto actions = Spawn::create(jump, scale, NULL);
auto jumpActions = Sequence::create(actions, callFunc, NULL);
this->runAction(jumpActions);
Config::score++;
}
开发者ID:Raymond-Wong,项目名称:Orbitum,代码行数:28,代码来源:Player.cpp
示例18: LogError
void TileObjectDoodad::draw(Renderer &r, TileView &view, Vec2<float> screenPosition,
TileViewMode mode)
{
std::ignore = view;
// Mode isn't used as TileView::tileToScreenCoords already transforms according to the mode
auto doodad = this->doodad.lock();
if (!doodad)
{
LogError("Called with no owning doodad object");
return;
}
sp<Image> sprite;
Vec2<float> transformedScreenPos = screenPosition;
switch (mode)
{
case TileViewMode::Isometric:
sprite = doodad->getSprite();
transformedScreenPos -= doodad->getImageOffset();
break;
case TileViewMode::Strategy:
// no doodads on strategy view?
return;
default:
LogError("Unsupported view mode");
}
r.draw(sprite, transformedScreenPos);
}
开发者ID:LucaAnt,项目名称:OpenApoc,代码行数:27,代码来源:tileobject_doodad.cpp
示例19: getSprite
//¶ÔÏóÊÇ·ñ±»´¥Ãþ
//bool BaseObject::containsTouchLocation(cocos2d::CCTouch *touch)
bool BaseObject::containsTouchLocation(CCPoint world_point)
{
CCSize size = getSprite()->getContentSize();
CCRect rect = CCRect(-size.width / 2.0, -size.height / 2.0, size.width, size.height);
//return rect.containsPoint(convertTouchToNodeSpaceAR(touch));
return rect.containsPoint(convertToNodeSpaceAR(world_point));
}
开发者ID:vincentRain,项目名称:SceneEditor,代码行数:9,代码来源:BaseObject.cpp
示例20: draw
void ShooterPlant::draw(sf::RenderWindow &window)
{
window.draw(*getSprite());
for (std::list<Bullet*>::iterator iter = getBulletList().begin(); iter != getBulletList().end(); iter++) {
window.draw((*iter)->getSprite());
}
}
开发者ID:sircuddles,项目名称:SvS,代码行数:7,代码来源:ShooterPlant.cpp
注:本文中的getSprite函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论