|
libscratchcpp
A library for C++ based Scratch project players
|
The Sprite class represents a Scratch sprite. More...
#include <scratchcpp/sprite.h>
Public Types | |
| enum class | RotationStyle { AllAround , LeftRight , DoNotRotate } |
Public Member Functions | |
| Sprite () | |
| Sprite (const Sprite &)=delete | |
| void | setInterface (ISpriteHandler *newInterface) |
| ISpriteHandler * | getInterface () const |
| std::shared_ptr< Sprite > | clone () |
| void | deleteClone () |
| bool | isClone () const |
| Sprite * | cloneSprite () const |
| const std::vector< std::shared_ptr< Sprite > > & | clones () const |
| bool | visible () const |
| void | setVisible (bool newVisible) |
| double | x () const |
| void | setX (double newX) |
| double | y () const |
| void | setY (double newY) |
| void | setPosition (double x, double y) |
| bool | dragging () const |
| void | startDragging () |
| void | stopDragging () |
| void | dragToPosition (double x, double y) |
| double | size () const |
| void | setSize (double newSize) |
| void | setCostumeIndex (int newCostumeIndex) override |
| int | currentCostumeWidth () const override |
| int | currentCostumeHeight () const override |
| double | direction () const |
| void | setDirection (double newDirection) |
| bool | draggable () const |
| void | setDraggable (bool newDraggable) |
| RotationStyle | rotationStyle () const |
| std::string | rotationStyleStr () const |
| void | setRotationStyle (RotationStyle newRotationStyle) |
| void | setRotationStyle (const std::string &newRotationStyle) |
| void | setRotationStyle (const char *newRotationStyle) |
| void | setLayerOrder (int newLayerOrder) override |
| Rect | boundingRect () const override |
| Rect | fastBoundingRect () const override |
| void | keepInFence (double newX, double newY, double *fencedX, double *fencedY) const |
| bool | touchingPoint (double x, double y) const override |
| bool | touchingColor (Rgb color) const override |
| bool | touchingColor (Rgb color, Rgb mask) const override |
| void | setGraphicsEffectValue (IGraphicsEffect *effect, double value) override |
| void | clearGraphicsEffects () override |
| bool | isTarget () const override final |
| virtual bool | isStage () const |
| const std::string & | name () const |
| void | setName (const std::string &name) |
| const std::vector< std::shared_ptr< Variable > > & | variables () const |
| int | addVariable (std::shared_ptr< Variable > variable) |
| std::shared_ptr< Variable > | variableAt (int index) const |
| int | findVariable (const std::string &variableName) const |
| int | findVariableById (const std::string &id) const |
| ValueData ** | variableData () |
| const std::vector< std::shared_ptr< List > > & | lists () const |
| int | addList (std::shared_ptr< List > list) |
| std::shared_ptr< List > | listAt (int index) const |
| int | findList (const std::string &listName) const |
| int | findListById (const std::string &id) const |
| List ** | listData () |
| const std::vector< std::shared_ptr< Block > > & | blocks () const |
| int | addBlock (std::shared_ptr< Block > block) |
| std::shared_ptr< Block > | blockAt (int index) const |
| int | findBlock (const std::string &id) const |
| std::vector< std::shared_ptr< Block > > | greenFlagBlocks () const |
| const std::vector< std::shared_ptr< Comment > > & | comments () const |
| int | addComment (std::shared_ptr< Comment > comment) |
| std::shared_ptr< Comment > | commentAt (int index) const |
| int | findComment (const std::string &id) const |
| int | costumeIndex () const |
| std::shared_ptr< Costume > | currentCostume () const |
| const std::vector< std::shared_ptr< Costume > > & | costumes () const |
| int | addCostume (std::shared_ptr< Costume > costume) |
| std::shared_ptr< Costume > | costumeAt (int index) const |
| int | findCostume (const std::string &costumeName) const |
| const std::vector< std::shared_ptr< Sound > > & | sounds () const |
| int | addSound (std::shared_ptr< Sound > sound) |
| std::shared_ptr< Sound > | soundAt (int index) const |
| int | findSound (const std::string &soundName) const |
| double | volume () const |
| void | setVolume (double newVolume) |
| virtual double | soundEffectValue (Sound::Effect effect) const |
| virtual void | setSoundEffectValue (Sound::Effect effect, double value) |
| virtual void | clearSoundEffects () |
| bool | touchingSprite (Sprite *sprite) const |
| bool | touchingEdge () const |
| double | graphicsEffectValue (IGraphicsEffect *effect) const |
| TextBubble * | bubble () |
| const TextBubble * | bubble () const |
| void | setEngine (IEngine *engine) override final |
| virtual bool | isTextBubble () const |
| int | layerOrder () const |
| sigslot::signal< int > & | layerOrderChanged () const |
| IEngine * | engine () const |
The Sprite class represents a Scratch sprite.
|
strong |
| Sprite::Sprite | ( | ) |
Constructs Sprite.
|
delete |
|
inherited |
Adds a block and returns its index.
|
inherited |
Adds a comment and returns its index.
|
inherited |
Adds a costume and returns its index.
|
inherited |
Adds a list and returns its index.
|
inherited |
Adds a sound and returns its index.
|
inherited |
Adds a variable and returns its index.
|
inherited |
Returns the block at index.
|
inherited |
Returns the list of blocks.
|
overridevirtual |
Overrides Target::boundingRect().
Reimplemented from libscratchcpp::Target.
|
inherited |
Returns the Bubble of this Target.
|
inherited |
Returns the Bubble of this Target.
|
overridevirtual |
Overrides Target::clearGraphicsEffects().
Reimplemented from libscratchcpp::Target.
|
virtualinherited |
Sets the value of all sound effects to 0 (clears them).
| std::shared_ptr< Sprite > Sprite::clone | ( | ) |
Creates a clone of the sprite.
| const std::vector< std::shared_ptr< Sprite > > & Sprite::clones | ( | ) | const |
Returns list of clones of the sprite.
| Sprite * Sprite::cloneSprite | ( | ) | const |
Returns the sprite this clone was created from, or nullptr if this isn't a clone.
|
inherited |
Returns the comment at index.
|
inherited |
Returns the list of comments in the code area.
|
inherited |
Returns the costume at index.
|
inherited |
Returns the index of the current costume.
|
inherited |
Returns the list of costumes.
|
inherited |
Returns the currently set costume.
|
overridevirtual |
Overrides Target::currentCostumeHeight().
Reimplemented from libscratchcpp::Target.
|
overridevirtual |
Overrides Target::currentCostumeWidth().
Reimplemented from libscratchcpp::Target.
| void Sprite::deleteClone | ( | ) |
Deletes this clone (if the sprite is a clone).
| double Sprite::direction | ( | ) | const |
Returns the direction.
| bool Sprite::draggable | ( | ) | const |
Returns true if the sprite is draggable.
| bool Sprite::dragging | ( | ) | const |
Returns true if the sprite is being dragged.
| void Sprite::dragToPosition | ( | double | x, |
| double | y ) |
Drags the sprite to the given position.
|
inherited |
Returns the engine.
|
overridevirtual |
Overrides Target::fastBoundingRect().
Reimplemented from libscratchcpp::Target.
|
inherited |
Returns the index of the block with the given ID.
|
inherited |
Returns the index of the comment with the given ID.
|
inherited |
Returns the index of the given costume.
|
inherited |
Returns the index of the list with the given name.
|
inherited |
Returns the index of the list with the given ID.
|
inherited |
Returns the index of the sound with the given name.
|
inherited |
Returns the index of the variable with the given name.
|
inherited |
Returns the index of the variable with the given ID.
| ISpriteHandler * Sprite::getInterface | ( | ) | const |
Returns the sprite interface.
|
inherited |
Returns the value of the given graphics effect.
|
inherited |
Returns list of all "when green flag clicked" blocks.
| bool Sprite::isClone | ( | ) | const |
Returns true if this is a clone.
|
inlinevirtualinherited |
Returns true if this Target is the stage.
Reimplemented in libscratchcpp::Stage.
|
finaloverridevirtualinherited |
Returns true.
Reimplemented from libscratchcpp::Drawable.
|
inlinevirtualinherited |
Returns true if this Drawable is a TextBubble.
Reimplemented in libscratchcpp::TextBubble.
| void Sprite::keepInFence | ( | double | newX, |
| double | newY, | ||
| double * | fencedX, | ||
| double * | fencedY ) const |
Keeps the desired position within the stage.
| [in] | New | desired X position. |
| [in] | New | desired Y position. |
| [out] | Fenced | X position. |
| [out] | Fenced | Y position. |
|
inherited |
Returns the layer number.
|
inherited |
Emits when the layer number changes.
|
inherited |
Returns the list at index.
|
inherited |
Returns an array of list pointers (for optimized list access).
|
inherited |
Returns the list of Scratch lists.
|
inherited |
Returns the name of the target.
| Sprite::RotationStyle Sprite::rotationStyle | ( | ) | const |
Returns the rotation style.
| std::string Sprite::rotationStyleStr | ( | ) | const |
Returns the rotation style as a string.
|
overridevirtual |
Overrides Target::setCostumeIndex().
Reimplemented from libscratchcpp::Target.
| void Sprite::setDirection | ( | double | newDirection | ) |
Sets the direction.
| void Sprite::setDraggable | ( | bool | newDraggable | ) |
Toggles whether the sprite is draggable.
|
finaloverridevirtualinherited |
Overrides Drawable::setEngine().
Reimplemented from libscratchcpp::Drawable.
|
overridevirtual |
Overrides Target::setGraphicsEffectValue().
Reimplemented from libscratchcpp::Target.
| void Sprite::setInterface | ( | ISpriteHandler * | newInterface | ) |
Sets the sprite interface.
|
overridevirtual |
Overrides Target::setLayerOrder().
Reimplemented from libscratchcpp::Drawable.
|
inherited |
Sets the name of the target.
| void Sprite::setPosition | ( | double | x, |
| double | y ) |
| void Sprite::setRotationStyle | ( | const char * | newRotationStyle | ) |
Sets the rotation style.
| void Sprite::setRotationStyle | ( | const std::string & | newRotationStyle | ) |
Sets the rotation style.
| void Sprite::setRotationStyle | ( | RotationStyle | newRotationStyle | ) |
Sets the rotation style.
| void Sprite::setSize | ( | double | newSize | ) |
Sets the size.
|
virtualinherited |
Sets the value of the given sound effect.
| void Sprite::setVisible | ( | bool | newVisible | ) |
Sets the visibility of the sprite.
|
inherited |
Sets the volume of all sounds of this target.
| void Sprite::setX | ( | double | newX | ) |
Sets the X position of the sprite.
| void Sprite::setY | ( | double | newY | ) |
Sets the Y position of the sprite.
| double Sprite::size | ( | ) | const |
Returns the size.
|
inherited |
Returns the sound at index.
|
virtualinherited |
Returns the value of the given sound effect.
|
inherited |
Returns the list of sounds.
| void Sprite::startDragging | ( | ) |
Starts dragging. Calls to setX(), setY() and setPosition() will be ignored until stopDragging() is called.
| void Sprite::stopDragging | ( | ) |
Stops dragging.
|
overridevirtual |
Overrides Target::touchingColor().
Reimplemented from libscratchcpp::Target.
Overrides Target::touchingColor().
Reimplemented from libscratchcpp::Target.
|
inherited |
Returns true if the target is touching the edge.
|
overridevirtual |
Overrides Target::touchingPoint().
Reimplemented from libscratchcpp::Target.
|
inherited |
|
inherited |
Returns the variable at index.
|
inherited |
Returns an array of raw variable data pointers (for optimized variable access).
|
inherited |
Returns the list of variables.
| bool Sprite::visible | ( | ) | const |
Returns true if the sprite is visible.
|
inherited |
Returns the volume.
| double Sprite::x | ( | ) | const |
Returns the X position of the sprite.
| double Sprite::y | ( | ) | const |
Returns the Y position of the sprite.