Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
- (Requested by AshMcConnell) Sprites used with Rectangles can be partially shown from the left/top position. See: Rectangle::background_image
  • Loading branch information
betajaen committed Sep 8, 2010
1 parent f1e8f9e commit 6a075c8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Gorilla.h
Expand Up @@ -1385,6 +1385,35 @@ namespace Gorilla
mLayer->_markDirty();
}

/*! function. background_image
desc.
Set the background to a sprite from the texture atlas, with clipping.
Clipping is used for example with RPM meters on HUDs, where a portion
of the sprite needs to be shown to indicate the RPM on the car.
widthClip is a decimal percentage of the width of the sprite (0.0 none, 1.0 full)
heightClip is a decimal percentage of the height of the sprite (0.0 none, 1.0 full)
You should use this with the width() and height() functions for a full effect.
note.
To remove the image pass on a null pointer.
*/
void background_image(Sprite* sprite, Ogre::Real widthClip, Ogre::Real heightClip)
{
if (sprite == 0)
{
mUV[0] = mUV[1] = mUV[2] = mUV[3] = mLayer->_getSolidUV();
}
else
{
mUV[0].x = mUV[3].x = sprite->uvLeft;
mUV[0].y = mUV[1].y = sprite->uvTop;
mUV[1].x = mUV[2].x = sprite->uvLeft + ( (sprite->uvRight - sprite->uvLeft) * widthClip );
mUV[2].y = mUV[3].y = sprite->uvTop + ( (sprite->uvBottom - sprite->uvTop) * heightClip );
}
mDirty = true;
mLayer->_markDirty();
}
/*! function. background_image
desc.
Set the background to a sprite from the texture atlas.
Expand Down

0 comments on commit 6a075c8

Please sign in to comment.