本文整理汇总了C++中setTextureRect函数的典型用法代码示例。如果您正苦于以下问题:C++ setTextureRect函数的具体用法?C++ setTextureRect怎么用?C++ setTextureRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setTextureRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTextureRect
void Sprite::setFlippedX(bool flippedX)
{
if (_flippedX != flippedX)
{
_flippedX = flippedX;
setTextureRect(_rect, _rectRotated, _contentSize);
}
}
示例2: setTextureRect
void NSpriteComponent::setTexture(sf::Texture& texture, sf::IntRect const& rect)
{
mSprite.setTexture(texture);
if (rect != sf::IntRect())
{
setTextureRect(rect);
}
}
示例3: switch
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;
}
}
示例4: setTexture
void AnimatedSprite::setAnimation(Animation& anim)
{
//reset();
animation = anim;
setTexture(animation.spriteSheet);
setTextureRect(animation.getFrame(iFrame));
setOrigin(getTextureRect().width / 2, getTextureRect().height / 2);
}
示例5: setTexture
void Drawable::setAnimation(bzsf::Animation& a) {
setTexture(*a.getTexture());
setTextureRect(a.getFrameRect());
anim = &a;
animIndex = anim->getIndex();
dType = ANIMATION;
}
示例6: setTextureRect
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]);
}
示例7: CCLOG
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);
}
示例8: setTexture
void Sprite::setDisplayFrame(const fzSpriteFrame& spriteFrame)
{
if(spriteFrame.isValid()) {
m_unflippedOffset = spriteFrame.getOffset();
setTexture(spriteFrame.getTexture());
setTextureRect(spriteFrame.getRect(), spriteFrame.getOriginalSize(), spriteFrame.isRotated());
}
}
示例9: m_type
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"));
}
示例10: setTextureRect
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;
}
示例11: setTextureRect
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));
}
}
示例12: AGameElement
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);
}
示例13: wyTextureNode
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;
}
示例14: setTextureRect
void Drawable::update(sf::Time dt) {
if(dType == ANIMATION) {
anim->update(dt);
if(anim->getIndex() != animIndex) {
animIndex = anim->getIndex();
setTextureRect(anim->getFrameRect());
}
}
}
示例15: setTexture
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);
}