File: Sprite.h

package info (click to toggle)
jazz2-native 3.5.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 16,912 kB
  • sloc: cpp: 172,557; xml: 113; python: 36; makefile: 5; sh: 2
file content (49 lines) | stat: -rw-r--r-- 1,662 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include "BaseSprite.h"

namespace nCine
{
	/// Scene node representing a regular sprite
	class Sprite : public BaseSprite
	{
	public:
		/// Default constructor for a sprite with no parent and no texture, positioned in the origin
		Sprite();
		/// Constructor for a sprite with a parent and texture, positioned in the relative origin
		Sprite(SceneNode* parent, Texture* texture);
		/// Constructor for a sprite with a texture but no parent, positioned in the origin
		explicit Sprite(Texture* texture);
		/// Constructor for a sprite with a parent, a texture and a specified relative position
		Sprite(SceneNode* parent, Texture* texture, float xx, float yy);
		/// Constructor for a sprite with a parent, a texture and a specified relative position as a vector
		Sprite(SceneNode* parent, Texture* texture, Vector2f position);
		/// Constructor for a sprite with a texture and a specified position but no parent
		Sprite(Texture* texture, float xx, float yy);
		/// Constructor for a sprite with a texture and a specified position as a vector but no parent
		Sprite(Texture* texture, Vector2f position);

		Sprite& operator=(const Sprite&) = delete;
		Sprite(Sprite&&) = default;
		Sprite& operator=(Sprite&&) = default;

		/// Returns a copy of this object
		inline Sprite clone() const {
			return Sprite(*this);
		}

		inline static ObjectType sType() {
			return ObjectType::Sprite;
		}

	protected:
		/// Protected copy constructor used to clone objects
		Sprite(const Sprite& other);

		void textureHasChanged(Texture* newTexture) override;

	private:
		/// Initializer method for constructors and the copy constructor
		void init();
	};
}