void Sprite::setFlippedX(bool flippedX) { if (_flippedX != flippedX) { _flippedX = flippedX; setTextureRect(_rect, _rectRotated, _contentSize); } }
void NSpriteComponent::setTexture(sf::Texture& texture, sf::IntRect const& rect) { mSprite.setTexture(texture); if (rect != sf::IntRect()) { setTextureRect(rect); } }
void Asteroid::setRandomImage() { // Pick a random sprite (each size has 6 sprites) int x = math::rand(0, 5); switch (m_size) { case BIG: setTextureRect(sf::IntRect(0 + x * 48, 0, 48, 48)); // 48*48px break; case MEDIUM: setTextureRect(sf::IntRect(0 + x * 32, 48, 32, 32)); // 32*32px break; case SMALL: setTextureRect(sf::IntRect(192 + x * 16, 48, 16, 16)); // 16*16px break; } }
void AnimatedSprite::setAnimation(Animation& anim) { //reset(); animation = anim; setTexture(animation.spriteSheet); setTextureRect(animation.getFrame(iFrame)); setOrigin(getTextureRect().width / 2, getTextureRect().height / 2); }
void Drawable::setAnimation(bzsf::Animation& a) { setTexture(*a.getTexture()); setTextureRect(a.getFrameRect()); anim = &a; animIndex = anim->getIndex(); dType = ANIMATION; }
void Sprite::setFlippedY(bool flippedY) { if (_flippedY != flippedY) { _flippedY = flippedY; setTextureRect(_rect, _rectRotated, _contentSize); } }
AnimatedGraphicElement::AnimatedGraphicElement(const std::vector<sf::IntRect>& clipRects, sf::Texture &image, int x, int y, int w, int h) :GraphicElement(image, x, y, w, h) { m_clipRects = clipRects; m_clipRect = 0; m_nb_etapes = 8; m_etape = 0; setTextureRect(m_clipRects[m_clipRect]); }
void MainScene::initCollisionSprite() { CCLOG("CollisionSprite初期化"); auto collisionSprite = Sprite::create(); collisionSprite->setAnchorPoint(Point(0, 0)); collisionSprite->setTextureRect(Rect(0, 0, 640, 100)); collisionSprite->setOpacity(0); collisionSprite->setPosition(0, 0); this->addChild(collisionSprite); }
void Sprite::setDisplayFrame(const fzSpriteFrame& spriteFrame) { if(spriteFrame.isValid()) { m_unflippedOffset = spriteFrame.getOffset(); setTexture(spriteFrame.getTexture()); setTextureRect(spriteFrame.getRect(), spriteFrame.getOriginalSize(), spriteFrame.isRotated()); } }
PowerUp::PowerUp(Type type): m_type(type) { int x = (type % 4) * POWERUP_WIDTH; int y = (type / 4) * POWERUP_HEIGHT; setTextureRect({x, y, POWERUP_WIDTH, POWERUP_HEIGHT}); setTexture(Resources::getTexture("power-ups.png")); }
void Shape::setTexture(const Texture* texture, bool resetRect) { // Recompute the texture area if requested, or if there was no texture before if (texture && (resetRect || !m_texture)) setTextureRect(IntRect(0, 0, texture->getWidth(), texture->getHeight())); // Assign the new texture m_texture = texture; }
void Hero_Digit::Change_Hero_Digit(sf::Event event) { if((event.key.code >= sf::Keyboard::Numpad1 && event.key.code <= sf::Keyboard::Numpad9) || (event.key.code >= sf::Keyboard::Num1 && event.key.code <= sf::Keyboard::Num9)) { number = hero_digit_map[event.key.code]; setTextureRect(sf::IntRect(((number + 2) % 3) * 100, ((number - 1) / 3) * 100, 100, 100)); } }
GameDecor::GameDecor(GameDecor const& model) : AGameElement(model),/* _image(model.getImage()),*/ _cadre(model.getCadre()), _vector(model.getVector1()), _movement(model.getVector2()) { // _texture.loadFromImage(_image); // _texture.setRepeated(model.sf::Sprite::getTexture()->isRepeated()); // _texture.setSmooth(true); // setTexture(_texture); setTextureRect(_cadre); }
wySpriteEx::wySpriteEx(wyTexture2D* pTex, wyZwoptexFrame* f) : wyTextureNode(pTex) { init(); setTextureRect(f->rect); setContentSize(f->sourceSize.width, f->sourceSize.height); setRotatedZwoptex(f->rotated); m_pointLeftBottom.x = f->sourceSize.width / 2 + f->offset.x - (f->rotated ? f->rect.height : f->rect.width) / 2; m_pointLeftBottom.y = f->sourceSize.height / 2 + f->offset.y - (f->rotated ? f->rect.width : f->rect.height) / 2; }
AnimatedGraphicElement::AnimatedGraphicElement(const AnimatedGraphicElement &copie) :GraphicElement(copie) { m_clipRects = copie.m_clipRects; m_clipRect = copie.m_clipRect; m_nb_etapes = copie.m_nb_etapes; m_etape = copie.m_etape; setTextureRect(m_clipRects[m_clipRect]); }
void Drawable::update(sf::Time dt) { if(dType == ANIMATION) { anim->update(dt); if(anim->getIndex() != animIndex) { animIndex = anim->getIndex(); setTextureRect(anim->getFrameRect()); } } }
void Sprite::setTexture(const std::string &filename) { Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); setTexture(texture); Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); setTextureRect(rect); }
void Sprite::setTexture(const Texture& texture, bool resetRect) { // Recompute the texture area if requested, or if there was no valid texture & rect before if (resetRect || (!m_texture && (m_textureRect == sf::IntRect()))) setTextureRect(IntRect(0, 0, texture.getSize().x, texture.getSize().y)); // Assign the new texture m_texture = &texture; }
void Sprite::setTexture(const Texture& texture, bool resetRect) { // Recompute the texture area if requested, or if there was no valid texture before if (resetRect || !m_texture) setTextureRect(IntRect(0, 0, texture.getWidth(), texture.getHeight())); // Assign the new texture m_texture = &texture; }
AnimatedSprite::AnimatedSprite(sf::Texture* texture, int width, int height, int yOffset, int xStep, int frames) { this->width = width; this->height = height; this->yOffset = yOffset; this->xStep = xStep; this->frames = frames; currentFrame = 0; setTexture(*texture); setTextureRect(sf::IntRect(0, yOffset, width, height)); }
bool CCSprite::initWithTexture(CCTexture2D *pTexture, CGRect rect) { assert(pTexture != NULL); // IMPORTANT: [self init] and not [super init]; init(); setTexture(pTexture); setTextureRect(rect); return true; }
void Rope::changePosition(Hanger * hanger) { double width = getContentSize().width; double height = getContentSize().height; double precent = abs((Global::getInstance()->getcentreY() - hanger->getCurrY()) / (sin(hanger->getAngle() / angleChange * pi))); double positionX = (Global::getInstance()->getcentreX() + hanger->getCurrX())/2; double positionY = (Global::getInstance()->getcentreY() + hanger->getCurrY())/2; setPosition(ccp(positionX,positionY )); setTextureRect(*new CCRect(0,(height-precent)/2,width,precent/0.8)); }
// MARK: texture void Sprite::setTexture(const std::string &filename) { Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); setTexture(texture); _unflippedOffsetPositionFromCenter = Vec2::ZERO; Rect rect = Rect::ZERO; if (texture) rect.size = texture->getContentSize(); setTextureRect(rect); }
Item(int i, std::string n, const sf::Texture &tex, const sf::IntRect I, int v,int d=0, int scale=30) { setTexture(tex); setTextureRect(I); name=n; id=i; value=v; damage=d; setScale(scale,scale); }
void AnimatedGraphicElement::draw(sf::RenderWindow *window) { m_etape++; if(m_etape>m_nb_etapes) { m_etape = 0; m_clipRect = m_clipRect % m_clipRects.size()+1; setTextureRect(m_clipRects[m_clipRect-1]); } window->draw(*this); }
Sprite::Sprite(const Texture& texture, const IntRect& rectangle) : m_verticesBuffer(TrianglesStrip, VertexBuffer::Stream), m_texture (NULL), m_textureRect () { if (VertexBuffer::isAvailable()) m_verticesBuffer.create(4); setTexture(texture); setTextureRect(rectangle); }
void nextFrame() { runTime = 0; currentFrame++; if (currentFrame>=animation->frames) { loops++; currentFrame = 0; if (!m_looped) m_destroy = true; } setTextureRect(sf::IntRect(currentFrame*animation->width, 0, animation->width, animation->height)); }
void AnimatedSprite::animate() { if (!frameUpdated) { //new texture set only when frame is changed setTextureRect(animation.getFrame(iFrame)); frameUpdated = true; } if (bPlaying) { if (timer.getElapsedTime().asSeconds() > animation.getSpeed()) { //Change Frame if (iFrame <= animation.getFrameCount()) { iFrame++; //Next Frame timer.restart(); } else { /* if (bLoop) { reset(); //Return to first frame timer.restart(); } else { iFrame--; //Return to previous frame bFinished = true; //Animation Cycle has finished stop(); //Stop Animation } */ } if (iFrame >= animation.getFrameCount()) { if (bLoop) { reset(); //Return to first frame timer.restart(); } else { iFrame--; //Return to previous frame bFinished = true; //Animation Cycle has finished stop(); //Stop Animation } } setTextureRect(animation.getFrame(iFrame)); //frameUpdated = false; } } }
void Shape::setTexture(const Texture* texture, bool resetRect) { if (texture) { // Recompute the texture area if requested, or if there was no texture & rect before if (resetRect || (!m_texture && (m_textureRect == sf::IntRect()))) setTextureRect(IntRect(0, 0, texture->getSize().x, texture->getSize().y)); } // Assign the new texture m_texture = texture; }
void Player::initPlayer(SpriteBatchNode* spriteBatchNode_) { setAnchorPoint(Point::ANCHOR_MIDDLE); // Create at the middle of the screen setPosition(Point(Director::getInstance()->getWinSize().width*0.5f, Director::getInstance()->getWinSize().height*0.5f)); // for prototyping setTextureRect(Rect(0.0f, 0.0f, PLAYER_WIDTH, PLAYER_HEIGHT)); setColor(Color3B(255, 255, 255)); setZOrder(2); }