libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Target Class Reference

The Target class is the Stage or a Sprite. More...

#include <scratchcpp/target.h>

Inheritance diagram for libscratchcpp::Target:
Collaboration diagram for libscratchcpp::Target:

Public Member Functions

 Target ()
 
 Target (const Target &)=delete
 
virtual ~Target ()
 
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< VariablevariableAt (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< ListlistAt (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< BlockblockAt (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< CommentcommentAt (int index) const
 
int findComment (const std::string &id) const
 
int costumeIndex () const
 
virtual void setCostumeIndex (int newCostumeIndex)
 
std::shared_ptr< CostumecurrentCostume () const
 
virtual int currentCostumeWidth () const
 
virtual int currentCostumeHeight () const
 
const std::vector< std::shared_ptr< Costume > > & costumes () const
 
int addCostume (std::shared_ptr< Costume > costume)
 
std::shared_ptr< CostumecostumeAt (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< SoundsoundAt (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 ()
 
virtual Rect boundingRect () const
 
virtual Rect fastBoundingRect () const
 
bool touchingSprite (Sprite *sprite) const
 
virtual bool touchingPoint (double x, double y) const
 
bool touchingEdge () const
 
virtual bool touchingColor (Rgb color) const
 
virtual bool touchingColor (Rgb color, Rgb mask) const
 
double graphicsEffectValue (IGraphicsEffect *effect) const
 
virtual void setGraphicsEffectValue (IGraphicsEffect *effect, double value)
 
virtual void clearGraphicsEffects ()
 
TextBubblebubble ()
 
const TextBubblebubble () const
 
void setEngine (IEngine *engine) override final
 
virtual bool isTextBubble () const
 
int layerOrder () const
 
virtual void setLayerOrder (int newLayerOrder)
 
sigslot::signal< int > & layerOrderChanged () const
 
IEngineengine () const
 

Protected Member Functions

virtual TargetdataSource () const
 
virtual bool touchingClones (const std::vector< Sprite * > &clones) const
 

Detailed Description

The Target class is the Stage or a Sprite.

Constructor & Destructor Documentation

◆ Target() [1/2]

Target::Target ( )

Constructs target.

◆ Target() [2/2]

libscratchcpp::Target::Target ( const Target & )
delete

◆ ~Target()

Target::~Target ( )
virtual

Destroys Target.

Member Function Documentation

◆ addBlock()

int Target::addBlock ( std::shared_ptr< Block > block)

Adds a block and returns its index.

◆ addComment()

int Target::addComment ( std::shared_ptr< Comment > comment)

Adds a comment and returns its index.

◆ addCostume()

int Target::addCostume ( std::shared_ptr< Costume > costume)

Adds a costume and returns its index.

◆ addList()

int Target::addList ( std::shared_ptr< List > list)

Adds a list and returns its index.

◆ addSound()

int Target::addSound ( std::shared_ptr< Sound > sound)

Adds a sound and returns its index.

◆ addVariable()

int Target::addVariable ( std::shared_ptr< Variable > variable)

Adds a variable and returns its index.

◆ blockAt()

std::shared_ptr< Block > Target::blockAt ( int index) const

Returns the block at index.

◆ blocks()

const std::vector< std::shared_ptr< Block > > & Target::blocks ( ) const

Returns the list of blocks.

◆ boundingRect()

Rect Target::boundingRect ( ) const
virtual

Returns the bounding rectangle of the sprite.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ bubble() [1/2]

TextBubble * Target::bubble ( )

Returns the Bubble of this Target.

◆ bubble() [2/2]

const TextBubble * Target::bubble ( ) const

Returns the Bubble of this Target.

◆ clearGraphicsEffects()

void Target::clearGraphicsEffects ( )
virtual

Sets the value of all graphics effects to 0 (clears them).

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ clearSoundEffects()

void Target::clearSoundEffects ( )
virtual

Sets the value of all sound effects to 0 (clears them).

◆ commentAt()

std::shared_ptr< Comment > Target::commentAt ( int index) const

Returns the comment at index.

◆ comments()

const std::vector< std::shared_ptr< Comment > > & Target::comments ( ) const

Returns the list of comments in the code area.

◆ costumeAt()

std::shared_ptr< Costume > Target::costumeAt ( int index) const

Returns the costume at index.

◆ costumeIndex()

int Target::costumeIndex ( ) const

Returns the index of the current costume.

◆ costumes()

const std::vector< std::shared_ptr< Costume > > & Target::costumes ( ) const

Returns the list of costumes.

◆ currentCostume()

std::shared_ptr< Costume > Target::currentCostume ( ) const

Returns the currently set costume.

◆ currentCostumeHeight()

int Target::currentCostumeHeight ( ) const
virtual

Returns the height of the current costume.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ currentCostumeWidth()

int Target::currentCostumeWidth ( ) const
virtual

Returns the width of the current costume.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ dataSource()

virtual Target * libscratchcpp::Target::dataSource ( ) const
inlineprotectedvirtual

Override this method to set a custom data source for blocks, assets, comments, etc.

◆ engine()

IEngine * Drawable::engine ( ) const
inherited

Returns the engine.

◆ fastBoundingRect()

Rect Target::fastBoundingRect ( ) const
virtual

Returns the less accurate bounding rectangle of the sprite which is calculated by transforming the costume rectangle.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ findBlock()

int Target::findBlock ( const std::string & id) const

Returns the index of the block with the given ID.

◆ findComment()

int Target::findComment ( const std::string & id) const

Returns the index of the comment with the given ID.

◆ findCostume()

int Target::findCostume ( const std::string & costumeName) const

Returns the index of the given costume.

◆ findList()

int Target::findList ( const std::string & listName) const

Returns the index of the list with the given name.

◆ findListById()

int Target::findListById ( const std::string & id) const

Returns the index of the list with the given ID.

◆ findSound()

int Target::findSound ( const std::string & soundName) const

Returns the index of the sound with the given name.

◆ findVariable()

int Target::findVariable ( const std::string & variableName) const

Returns the index of the variable with the given name.

◆ findVariableById()

int Target::findVariableById ( const std::string & id) const

Returns the index of the variable with the given ID.

◆ graphicsEffectValue()

double Target::graphicsEffectValue ( IGraphicsEffect * effect) const

Returns the value of the given graphics effect.

◆ greenFlagBlocks()

std::vector< std::shared_ptr< Block > > Target::greenFlagBlocks ( ) const

Returns list of all "when green flag clicked" blocks.

◆ isStage()

virtual bool libscratchcpp::Target::isStage ( ) const
inlinevirtual

Returns true if this Target is the stage.

Reimplemented in libscratchcpp::Stage.

◆ isTarget()

bool Target::isTarget ( ) const
finaloverridevirtual

Returns true.

Reimplemented from libscratchcpp::Drawable.

◆ isTextBubble()

virtual bool libscratchcpp::Drawable::isTextBubble ( ) const
inlinevirtualinherited

Returns true if this Drawable is a TextBubble.

Reimplemented in libscratchcpp::TextBubble.

◆ layerOrder()

int Drawable::layerOrder ( ) const
inherited

Returns the layer number.

◆ layerOrderChanged()

sigslot::signal< int > & Drawable::layerOrderChanged ( ) const
inherited

Emits when the layer number changes.

◆ listAt()

std::shared_ptr< List > Target::listAt ( int index) const

Returns the list at index.

◆ listData()

List ** Target::listData ( )

Returns an array of list pointers (for optimized list access).

◆ lists()

const std::vector< std::shared_ptr< List > > & Target::lists ( ) const

Returns the list of Scratch lists.

◆ name()

const std::string & Target::name ( ) const

Returns the name of the target.

◆ setCostumeIndex()

void Target::setCostumeIndex ( int newCostumeIndex)
virtual

Sets the index of the current costume.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ setEngine()

void Target::setEngine ( IEngine * engine)
finaloverridevirtual

Overrides Drawable::setEngine().

Reimplemented from libscratchcpp::Drawable.

◆ setGraphicsEffectValue()

void Target::setGraphicsEffectValue ( IGraphicsEffect * effect,
double value )
virtual

Sets the value of the given graphics effect.

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ setLayerOrder()

void Drawable::setLayerOrder ( int newLayerOrder)
virtualinherited

Sets the layer number.

Reimplemented in libscratchcpp::Sprite.

◆ setName()

void Target::setName ( const std::string & name)

Sets the name of the target.

Note
Setting the name to one of the reserved names (mouse, stage, edge, myself, random) won't do anything.

◆ setSoundEffectValue()

void Target::setSoundEffectValue ( Sound::Effect effect,
double value )
virtual

Sets the value of the given sound effect.

◆ setVolume()

void Target::setVolume ( double newVolume)

Sets the volume of all sounds of this target.

◆ soundAt()

std::shared_ptr< Sound > Target::soundAt ( int index) const

Returns the sound at index.

◆ soundEffectValue()

double Target::soundEffectValue ( Sound::Effect effect) const
virtual

Returns the value of the given sound effect.

◆ sounds()

const std::vector< std::shared_ptr< Sound > > & Target::sounds ( ) const

Returns the list of sounds.

◆ touchingClones()

virtual bool libscratchcpp::Target::touchingClones ( const std::vector< Sprite * > & clones) const
inlineprotectedvirtual

Override this method to check whether the target touches the given sprite clones.

◆ touchingColor() [1/2]

bool Target::touchingColor ( Rgb color) const
virtual

Returns true if the Target is touching the given color (RGB triplet).

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ touchingColor() [2/2]

bool Target::touchingColor ( Rgb color,
Rgb mask ) const
virtual

Returns true if the mask part of the Target is touching the given color (RGB triplet).

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ touchingEdge()

bool Target::touchingEdge ( ) const

Returns true if the target is touching the edge.

◆ touchingPoint()

bool Target::touchingPoint ( double x,
double y ) const
virtual

Returns true if the Target is touching the given point (in Scratch coordinates).

Reimplemented in libscratchcpp::Sprite, and libscratchcpp::Stage.

◆ touchingSprite()

bool Target::touchingSprite ( Sprite * sprite) const

Returns true if the Target is touching the given Sprite (or its clones).

◆ variableAt()

std::shared_ptr< Variable > Target::variableAt ( int index) const

Returns the variable at index.

◆ variableData()

ValueData ** Target::variableData ( )

Returns an array of raw variable data pointers (for optimized variable access).

◆ variables()

const std::vector< std::shared_ptr< Variable > > & Target::variables ( ) const

Returns the list of variables.

◆ volume()

double Target::volume ( ) const

Returns the volume.


The documentation for this class was generated from the following files: