Beispiel #1
0
/*!
 * \param f frame number
 */
void AnimatedSprite::setFrame(int f)
{
    lock();
    RANGERS_D(AnimatedSprite);
    d->currentFrame = f;
    unlock();
}
Beispiel #2
0
void Label::setFont(boost::shared_ptr<Font> font)
{
    lock();
    RANGERS_D(Label);
    d->font = font;
    markToUpdate();
    unlock();
}
Beispiel #3
0
void Label::setWordWrap(bool wordWrap)
{
    lock();
    RANGERS_D(Label);
    d->wordWrap = wordWrap;
    markToUpdate();
    unlock();
}
Beispiel #4
0
void Label::setText(const std::string& text)
{
    lock();
    RANGERS_D(Label);
    d->text = text;
    markToUpdate();
    unlock();
}
Beispiel #5
0
void AnimatedSprite::reset()
{
    lock();
    RANGERS_D(AnimatedSprite);
    d->animationStarted = false;
    d->currentFrame = 0;
    d->animationTime = 0;
    unlock();
}
Beispiel #6
0
void Node::processLogic(int dt)
{
    RANGERS_D(Node);
    lock();
    std::list<Object*> children = d->children;
    unlock();
    for (std::list<Object*>::const_iterator i = children.begin(); i != children.end(); i++)
        (*i)->processLogic(dt);
}
Beispiel #7
0
Label::Label(const std::string& text, boost::shared_ptr<Font> font): Sprite(*(new LabelPrivate()))
{
    RANGERS_D(Label);
    if (!font)
        d->font = Engine::instance().coreFont();
    else
        d->font = font;

    setText(text);
}
Beispiel #8
0
void Label::setFixedHeight(float h)
{
    RANGERS_D(Label);
    d->fixedHeight  = true;
    if (h > 0)
        d->height = h;
    else
        d->fixedHeight = false;
    markToUpdate();
}
Beispiel #9
0
void Label::setFixedWidth(float w)
{
    RANGERS_D(Label);
    d->fixedWidth  = true;
    if (w > 0)
        d->width = w;
    else
        d->fixedWidth = false;
    markToUpdate();
}
Beispiel #10
0
/*!
 * \param texture texture
 * \param parent object parent
 */
AnimatedSprite::AnimatedSprite(boost::shared_ptr<AnimatedTexture> texture):
    Sprite(*(new AnimatedSpritePrivate()))
{
    RANGERS_D(AnimatedSprite);
    d->region = TextureRegion(texture);
    if (texture)
    {
        d->width = texture->width();
        d->height = texture->height();
        start();
    }
}
Beispiel #11
0
/*!
 * \param animation animation resource name
 * \param parent object parent
 */
AnimatedSprite::AnimatedSprite(const std::string& animation):
    Sprite(*(new AnimatedSpritePrivate()))
{
    RANGERS_D(AnimatedSprite);
    boost::shared_ptr<AnimatedTexture> animTexture = ResourceManager::instance().loadAnimation(animation);
    d->region = TextureRegion(animTexture);
    if (animTexture)
    {
        d->width = animTexture->width();
        d->height = animTexture->height();
        start();
    }
    markToUpdate();
}
Beispiel #12
0
void Label::setFixedSize(float width, float height)
{
    lock();
    RANGERS_D(Label);
    if ((width > 0) && (height > 0))
    {
        d->width = width;
        d->height = height;
        d->fixedHeight  = true;
        d->fixedWidth  = true;
    }
    else
    {
        d->fixedHeight  = false;
        d->fixedWidth  = false;
    }
    markToUpdate();
    unlock();
}
Beispiel #13
0
void Label::processMain()
{
    RANGERS_D(Label);
    if (!d->font)
        return;
    lock();

    if (!d->wordWrap)
        d->region = TextureRegion(d->font->renderText(fromUTF8(d->text.c_str())));
    else
        d->region = TextureRegion(d->font->renderText(fromUTF8(d->text.c_str()), d->width));

    if (!d->fixedWidth)
        d->width = d->region.texture->width();
    if (!d->fixedHeight)
        d->height = d->region.texture->height();

    unlock();
    Sprite::processMain();
}
Beispiel #14
0
void TiledBeizerCurve::calcCurve()
{
    RANGERS_D(TiledBeizerCurve);

    std::list<Vector> points;

    Vector dir;
    Vector p0 = d->calcBezierPoint(0.0f, dir);
    Vector p1 = d->calcBezierPoint(1.0f, dir);
    points.push_back(p0);
    points.push_back(p1);

    std::list<Vector>::iterator i = points.begin();
    ++i;

    d->findPoints(0.0f, 1.0f, points, i);
    d->points = std::vector<Vector>(points.size());
    std::copy(points.begin(), points.end(), d->points.begin());

    markToUpdate();
}
Beispiel #15
0
void TiledBeizerCurve::setCurve(const BeizerCurve& curve)
{
    RANGERS_D(TiledBeizerCurve);
    d->curve = curve;
    calcCurve();
}
Beispiel #16
0
TiledBeizerCurve::TiledBeizerCurve(const std::string& texture): TiledPolyline(*(new TiledBeizerCurvePrivate()))
{
    RANGERS_D(TiledBeizerCurve);
    d->texture = ResourceManager::instance().loadTexture(texture);
}
Beispiel #17
0
TiledBeizerCurve::TiledBeizerCurve(boost::shared_ptr<Texture> texture): TiledPolyline(*(new TiledBeizerCurvePrivate()))
{
    RANGERS_D(TiledBeizerCurve);
    d->texture = texture;
}