2011-12-02 06:24:58 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// SFML - Simple and Fast Multimedia Library
|
2013-04-06 15:34:44 +08:00
|
|
|
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
2011-12-02 06:24:58 +08:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
// subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented;
|
|
|
|
// you must not claim that you wrote the original software.
|
|
|
|
// If you use this software in a product, an acknowledgment
|
|
|
|
// in the product documentation would be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such,
|
|
|
|
// and must not be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SFML_TRANSFORMABLE_HPP
|
|
|
|
#define SFML_TRANSFORMABLE_HPP
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Headers
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-01-21 17:34:17 +08:00
|
|
|
#include <SFML/Graphics/Export.hpp>
|
2011-12-02 06:24:58 +08:00
|
|
|
#include <SFML/Graphics/Transform.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace sf
|
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Decomposed transform defined by a position, a rotation and a scale
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-01-21 17:34:17 +08:00
|
|
|
class SFML_GRAPHICS_API Transformable
|
2011-12-02 06:24:58 +08:00
|
|
|
{
|
|
|
|
public :
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Default constructor
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
Transformable();
|
|
|
|
|
2011-12-20 00:50:15 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Virtual destructor
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
virtual ~Transformable();
|
|
|
|
|
2011-12-02 06:24:58 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the position of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// This function completely overwrites the previous position.
|
2012-07-15 20:55:13 +08:00
|
|
|
/// See the move function to apply an offset based on the previous position instead.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// The default position of a transformable object is (0, 0).
|
|
|
|
///
|
|
|
|
/// \param x X coordinate of the new position
|
|
|
|
/// \param y Y coordinate of the new position
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see move, getPosition
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setPosition(float x, float y);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the position of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// This function completely overwrites the previous position.
|
2012-07-15 20:55:13 +08:00
|
|
|
/// See the move function to apply an offset based on the previous position instead.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// The default position of a transformable object is (0, 0).
|
|
|
|
///
|
|
|
|
/// \param position New position
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see move, getPosition
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setPosition(const Vector2f& position);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the orientation of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// This function completely overwrites the previous rotation.
|
2012-07-15 20:55:13 +08:00
|
|
|
/// See the rotate function to add an angle based on the previous rotation instead.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// The default rotation of a transformable object is 0.
|
|
|
|
///
|
|
|
|
/// \param angle New rotation, in degrees
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see rotate, getRotation
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setRotation(float angle);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the scale factors of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// This function completely overwrites the previous scale.
|
2012-07-15 20:55:13 +08:00
|
|
|
/// See the scale function to add a factor based on the previous scale instead.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// The default scale of a transformable object is (1, 1).
|
|
|
|
///
|
|
|
|
/// \param factorX New horizontal scale factor
|
|
|
|
/// \param factorY New vertical scale factor
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see scale, getScale
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setScale(float factorX, float factorY);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the scale factors of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// This function completely overwrites the previous scale.
|
2012-07-15 20:55:13 +08:00
|
|
|
/// See the scale function to add a factor based on the previous scale instead.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// The default scale of a transformable object is (1, 1).
|
|
|
|
///
|
|
|
|
/// \param factors New scale factors
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see scale, getScale
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setScale(const Vector2f& factors);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the local origin of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// The origin of an object defines the center point for
|
|
|
|
/// all transformations (position, scale, rotation).
|
|
|
|
/// The coordinates of this point must be relative to the
|
|
|
|
/// top-left corner of the object, and ignore all
|
|
|
|
/// transformations (position, scale, rotation).
|
|
|
|
/// The default origin of a transformable object is (0, 0).
|
|
|
|
///
|
|
|
|
/// \param x X coordinate of the new origin
|
|
|
|
/// \param y Y coordinate of the new origin
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see getOrigin
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setOrigin(float x, float y);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief set the local origin of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// The origin of an object defines the center point for
|
|
|
|
/// all transformations (position, scale, rotation).
|
|
|
|
/// The coordinates of this point must be relative to the
|
|
|
|
/// top-left corner of the object, and ignore all
|
|
|
|
/// transformations (position, scale, rotation).
|
|
|
|
/// The default origin of a transformable object is (0, 0).
|
|
|
|
///
|
|
|
|
/// \param origin New origin
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see getOrigin
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void setOrigin(const Vector2f& origin);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the position of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// \return Current position
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setPosition
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
const Vector2f& getPosition() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the orientation of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// The rotation is always in the range [0, 360].
|
|
|
|
///
|
|
|
|
/// \return Current rotation, in degrees
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setRotation
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
float getRotation() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the current scale of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// \return Current scale factors
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setScale
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
const Vector2f& getScale() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the local origin of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// \return Current origin
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setOrigin
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
const Vector2f& getOrigin() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Move the object by a given offset
|
|
|
|
///
|
|
|
|
/// This function adds to the current position of the object,
|
2012-03-12 02:10:37 +08:00
|
|
|
/// unlike setPosition which overwrites it.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// Thus, it is equivalent to the following code:
|
|
|
|
/// \code
|
2012-03-12 02:10:37 +08:00
|
|
|
/// sf::Vector2f pos = object.getPosition();
|
|
|
|
/// object.setPosition(pos.x + offsetX, pos.y + offsetY);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \param offsetX X offset
|
|
|
|
/// \param offsetY Y offset
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setPosition
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void move(float offsetX, float offsetY);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Move the object by a given offset
|
|
|
|
///
|
|
|
|
/// This function adds to the current position of the object,
|
2012-03-12 02:10:37 +08:00
|
|
|
/// unlike setPosition which overwrites it.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// Thus, it is equivalent to the following code:
|
|
|
|
/// \code
|
2012-03-12 02:10:37 +08:00
|
|
|
/// object.setPosition(object.getPosition() + offset);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \param offset Offset
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setPosition
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void move(const Vector2f& offset);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Rotate the object
|
|
|
|
///
|
|
|
|
/// This function adds to the current rotation of the object,
|
2012-03-12 02:10:37 +08:00
|
|
|
/// unlike setRotation which overwrites it.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// Thus, it is equivalent to the following code:
|
|
|
|
/// \code
|
2012-03-12 02:10:37 +08:00
|
|
|
/// object.setRotation(object.getRotation() + angle);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \param angle Angle of rotation, in degrees
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void rotate(float angle);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Scale the object
|
|
|
|
///
|
|
|
|
/// This function multiplies the current scale of the object,
|
2012-03-12 02:10:37 +08:00
|
|
|
/// unlike setScale which overwrites it.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// Thus, it is equivalent to the following code:
|
|
|
|
/// \code
|
2012-03-12 02:10:37 +08:00
|
|
|
/// sf::Vector2f scale = object.getScale();
|
|
|
|
/// object.setScale(scale.x * factorX, scale.y * factorY);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \param factorX Horizontal scale factor
|
|
|
|
/// \param factorY Vertical scale factor
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setScale
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void scale(float factorX, float factorY);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Scale the object
|
|
|
|
///
|
|
|
|
/// This function multiplies the current scale of the object,
|
2012-03-12 02:10:37 +08:00
|
|
|
/// unlike setScale which overwrites it.
|
2011-12-02 06:24:58 +08:00
|
|
|
/// Thus, it is equivalent to the following code:
|
|
|
|
/// \code
|
2012-03-12 02:10:37 +08:00
|
|
|
/// sf::Vector2f scale = object.getScale();
|
|
|
|
/// object.setScale(scale.x * factor.x, scale.y * factor.y);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \param factor Scale factors
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see setScale
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
void scale(const Vector2f& factor);
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the combined transform of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
/// \return Transform combining the position/rotation/scale/origin of the object
|
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see getInverseTransform
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
const Transform& getTransform() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \brief get the inverse of the combined transform of the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
2012-01-26 00:37:55 +08:00
|
|
|
/// \return Inverse of the combined transformations applied to the object
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
2012-03-12 02:10:37 +08:00
|
|
|
/// \see getTransform
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-12 02:10:37 +08:00
|
|
|
const Transform& getInverseTransform() const;
|
2011-12-02 06:24:58 +08:00
|
|
|
|
|
|
|
private :
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Member data
|
|
|
|
////////////////////////////////////////////////////////////
|
2012-03-09 08:22:47 +08:00
|
|
|
Vector2f m_origin; ///< Origin of translation/rotation/scaling of the object
|
|
|
|
Vector2f m_position; ///< Position of the object in the 2D world
|
|
|
|
float m_rotation; ///< Orientation of the object, in degrees
|
|
|
|
Vector2f m_scale; ///< Scale of the object
|
|
|
|
mutable Transform m_transform; ///< Combined transformation of the object
|
|
|
|
mutable bool m_transformNeedUpdate; ///< Does the transform need to be recomputed?
|
|
|
|
mutable Transform m_inverseTransform; ///< Combined transformation of the object
|
|
|
|
mutable bool m_inverseTransformNeedUpdate; ///< Does the transform need to be recomputed?
|
2011-12-02 06:24:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sf
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SFML_TRANSFORMABLE_HPP
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \class sf::Transformable
|
|
|
|
/// \ingroup graphics
|
|
|
|
///
|
|
|
|
/// This class is provided for convenience, on top of sf::Transform.
|
|
|
|
///
|
|
|
|
/// sf::Transform, as a low-level class, offers a great level of
|
|
|
|
/// flexibility but it is not always convenient to manage. Indeed,
|
|
|
|
/// one can easily combine any kind of operation, such as a translation
|
|
|
|
/// followed by a rotation followed by a scaling, but once the result
|
|
|
|
/// transform is built, there's no way to go backward and, let's say,
|
|
|
|
/// change only the rotation without modifying the translation and scaling.
|
|
|
|
/// The entire transform must be recomputed, which means that you
|
|
|
|
/// need to retrieve the initial translation and scale factors as
|
|
|
|
/// well, and combine them the same way you did before updating the
|
|
|
|
/// rotation. This is a tedious operation, and it requires to store
|
|
|
|
/// all the individual components of the final transform.
|
|
|
|
///
|
|
|
|
/// That's exactly what sf::Transformable was written for: it hides
|
|
|
|
/// these variables and the composed transform behind an easy to use
|
|
|
|
/// interface. You can set or get any of the individual components
|
|
|
|
/// without worrying about the others. It also provides the composed
|
|
|
|
/// transform (as a sf::Transform), and keeps it up-to-date.
|
|
|
|
///
|
|
|
|
/// In addition to the position, rotation and scale, sf::Transformable
|
|
|
|
/// provides an "origin" component, which represents the local origin
|
|
|
|
/// of the three other components. Let's take an example with a 10x10
|
2013-05-11 14:51:20 +08:00
|
|
|
/// pixels sprite. By default, the sprite is positioned/rotated/scaled
|
2011-12-02 06:24:58 +08:00
|
|
|
/// relatively to its top-left corner, because it is the local point
|
|
|
|
/// (0, 0). But if we change the origin to be (5, 5), the sprite will
|
2013-05-11 14:51:20 +08:00
|
|
|
/// be positioned/rotated/scaled around its center instead. And if
|
2011-12-02 06:24:58 +08:00
|
|
|
/// we set the origin to (10, 10), it will be transformed around its
|
|
|
|
/// bottom-right corner.
|
|
|
|
///
|
|
|
|
/// To keep the sf::Transformable class simple, there's only one
|
|
|
|
/// origin for all the components. You cannot position the sprite
|
|
|
|
/// relatively to its top-left corner while rotating it around its
|
|
|
|
/// center, for example. To do such things, use sf::Transform directly.
|
|
|
|
///
|
|
|
|
/// sf::Transformable can be used as a base class. It is often
|
|
|
|
/// combined with sf::Drawable -- that's what SFML's sprites,
|
|
|
|
/// texts and shapes do.
|
|
|
|
/// \code
|
|
|
|
/// class MyEntity : public sf::Transformable, public sf::Drawable
|
|
|
|
/// {
|
2012-03-12 02:10:37 +08:00
|
|
|
/// virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
|
2011-12-02 06:24:58 +08:00
|
|
|
/// {
|
2012-03-12 02:10:37 +08:00
|
|
|
/// states.transform *= getTransform();
|
|
|
|
/// target.draw(..., states);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// }
|
|
|
|
/// };
|
|
|
|
///
|
|
|
|
/// MyEntity entity;
|
2012-03-12 02:10:37 +08:00
|
|
|
/// entity.setPosition(10, 20);
|
|
|
|
/// entity.setRotation(45);
|
|
|
|
/// window.draw(entity);
|
2011-12-02 06:24:58 +08:00
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// It can also be used as a member, if you don't want to use
|
|
|
|
/// its API directly (because you don't need all its functions,
|
|
|
|
/// or you have different naming conventions for example).
|
|
|
|
/// \code
|
|
|
|
/// class MyEntity
|
|
|
|
/// {
|
|
|
|
/// public :
|
2012-08-23 23:15:03 +08:00
|
|
|
/// void SetPosition(const MyVector& v)
|
2011-12-02 06:24:58 +08:00
|
|
|
/// {
|
2012-08-23 23:15:03 +08:00
|
|
|
/// myTransform.setPosition(v.x(), v.y());
|
2011-12-02 06:24:58 +08:00
|
|
|
/// }
|
|
|
|
///
|
2012-08-23 23:15:03 +08:00
|
|
|
/// void Draw(sf::RenderTarget& target) const
|
2011-12-02 06:24:58 +08:00
|
|
|
/// {
|
2012-08-23 23:15:03 +08:00
|
|
|
/// target.draw(..., myTransform.getTransform());
|
2011-12-02 06:24:58 +08:00
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// private :
|
2012-08-23 23:15:03 +08:00
|
|
|
/// sf::Transformable myTransform;
|
2011-12-02 06:24:58 +08:00
|
|
|
/// };
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// \see sf::Transform
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|