| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- $#include "Sprite.h"
- enum BlendMode{};
- /// %UI element which allows sub-pixel positioning and size, as well as rotation. Only other Sprites should be added as child elements.
- class Sprite : public UIElement
- {
- public:
- /// Construct.
- Sprite(Context* context);
- /// Destruct.
- virtual ~Sprite();
- /// Set floating point position.
- void SetPosition(const Vector2& position);
- /// Set floating point position.
- void SetPosition(float x, float y);
- /// Set hotspot for positioning and rotation.
- void SetHotSpot(const IntVector2& hotSpot);
- /// Set hotspot for positioning and rotation.
- void SetHotSpot(int x, int y);
- /// Set scale. Scale also affects child sprites.
- void SetScale(const Vector2& scale);
- /// Set scale. Scale also affects child sprites.
- void SetScale(float x, float y);
- /// Set uniform scale. Scale also affects child sprites.
- void SetScale(float scale);
- /// Set rotation angle.
- void SetRotation(float angle);
- /// Set texture.
- void SetTexture(Texture* texture);
- /// Set part of texture to use as the image.
- void SetImageRect(const IntRect& rect);
- /// Use whole texture as the image.
- void SetFullImageRect();
- /// Set blend mode.
- void SetBlendMode(BlendMode mode);
-
- /// Return floating point position.
- const Vector2& GetPosition() const { return floatPosition_; }
- /// Return hotspot.
- const IntVector2& GetHotSpot() const { return hotSpot_; }
- /// Return scale.
- const Vector2& GetScale() const { return scale_; }
- /// Return rotation angle.
- float GetRotation() const { return rotation_; }
- /// Return texture.
- Texture* GetTexture() const { return texture_; }
- /// Return image rectangle.
- const IntRect& GetImageRect() const { return imageRect_; }
- /// Return blend mode.
- BlendMode GetBlendMode() const { return blendMode_; }
-
- /// Set texture attribute.
- void SetTextureAttr(ResourceRef value);
- /// Return texture attribute.
- ResourceRef GetTextureAttr() const;
- /// Update and return rendering transform, also used to transform child sprites.
- const Matrix3x4& GetTransform() const;
- };
- /// Create sprite without lua GC.
- Sprite* NewSprite(Context* context);
- /// Delete sprite.
- void Delete(Sprite* sprite);
- ${
- static Sprite* NewSprite(Context* context)
- {
- return new Sprite(context);
- }
- static void Delete(Sprite* sprite)
- {
- delete sprite;
- }
- $}
|