libscratchcpp
A library for C++ based Scratch project players
Toggle main menu visibility
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
3
#pragma once
4
5
#include <vector>
6
#include <
scratchcpp/value_functions.h
>
7
8
#include "
drawable.h
"
9
#include "
rect.h
"
10
#include "
sound.h
"
11
12
namespace
libscratchcpp
13
{
14
15
class
Variable
;
16
class
List
;
17
class
Block
;
18
class
Comment
;
19
class
Costume
;
20
class
Sound
;
21
class
Sprite
;
22
class
TextBubble
;
23
class
IGraphicsEffect
;
24
class
TargetPrivate;
25
27
class
LIBSCRATCHCPP_EXPORT
Target
:
public
Drawable
28
{
29
public
:
30
Target
();
31
Target
(
const
Target
&) =
delete
;
32
virtual
~Target
();
33
34
bool
isTarget
() const override final;
35
37
virtual
bool
isStage
()
const
{
return
false
; }
38
39
const
std::string &name()
const
;
40
void
setName(
const
std::string &name);
41
42
const
std::vector<std::shared_ptr<Variable>> &variables()
const
;
43
int
addVariable(std::shared_ptr<Variable> variable);
44
std::shared_ptr<Variable> variableAt(
int
index)
const
;
45
int
findVariable(
const
std::string &variableName)
const
;
46
int
findVariableById(
const
std::string &
id
)
const
;
47
48
ValueData
**variableData();
49
50
const
std::vector<std::shared_ptr<List>> &lists()
const
;
51
int
addList(std::shared_ptr<List> list);
52
std::shared_ptr<List> listAt(
int
index)
const
;
53
int
findList(
const
std::string &listName)
const
;
54
int
findListById(
const
std::string &
id
)
const
;
55
56
List
**listData();
57
58
const
std::vector<std::shared_ptr<Block>> &blocks()
const
;
59
int
addBlock(std::shared_ptr<Block> block);
60
std::shared_ptr<Block> blockAt(
int
index)
const
;
61
int
findBlock(
const
std::string &
id
)
const
;
62
std::vector<std::shared_ptr<Block>> greenFlagBlocks()
const
;
63
64
const
std::vector<std::shared_ptr<Comment>> &comments()
const
;
65
int
addComment(std::shared_ptr<Comment> comment);
66
std::shared_ptr<Comment> commentAt(
int
index)
const
;
67
int
findComment(
const
std::string &
id
)
const
;
68
69
int
costumeIndex()
const
;
70
virtual
void
setCostumeIndex(
int
newCostumeIndex);
71
72
std::shared_ptr<Costume> currentCostume()
const
;
73
virtual
int
currentCostumeWidth()
const
;
74
virtual
int
currentCostumeHeight()
const
;
75
76
const
std::vector<std::shared_ptr<Costume>> &costumes()
const
;
77
int
addCostume(std::shared_ptr<Costume> costume);
78
std::shared_ptr<Costume> costumeAt(
int
index)
const
;
79
int
findCostume(
const
std::string &costumeName)
const
;
80
81
const
std::vector<std::shared_ptr<Sound>> &sounds()
const
;
82
int
addSound(std::shared_ptr<Sound> sound);
83
std::shared_ptr<Sound> soundAt(
int
index)
const
;
84
int
findSound(
const
std::string &soundName)
const
;
85
86
double
volume()
const
;
87
void
setVolume(
double
newVolume);
88
89
virtual
double
soundEffectValue(
Sound::Effect
effect)
const
;
90
virtual
void
setSoundEffectValue(
Sound::Effect
effect,
double
value);
91
92
virtual
void
clearSoundEffects();
93
94
virtual
Rect
boundingRect()
const
;
95
virtual
Rect
fastBoundingRect()
const
;
96
97
bool
touchingSprite(
Sprite
*sprite)
const
;
98
virtual
bool
touchingPoint(
double
x,
double
y)
const
;
99
bool
touchingEdge()
const
;
100
virtual
bool
touchingColor(
Rgb
color)
const
;
101
virtual
bool
touchingColor(
Rgb
color,
Rgb
mask)
const
;
102
103
double
graphicsEffectValue(
IGraphicsEffect
*effect)
const
;
104
virtual
void
setGraphicsEffectValue(
IGraphicsEffect
*effect,
double
value);
105
106
virtual
void
clearGraphicsEffects();
107
108
TextBubble
*bubble();
109
const
TextBubble
*bubble()
const
;
110
111
void
setEngine(
IEngine
*engine)
override
final
;
112
113
protected
:
115
virtual
Target
*
dataSource
()
const
{
return
nullptr
; }
116
118
virtual
bool
touchingClones
(
const
std::vector<Sprite *> &clones)
const
{
return
false
; }
119
120
private
:
121
spimpl::unique_impl_ptr<TargetPrivate> impl;
122
};
123
124
}
// namespace libscratchcpp
libscratchcpp::Block
The Block class represents a Scratch block.
Definition
block.h:24
libscratchcpp::Comment
The Comment class represents a comment in the code area.
Definition
comment.h:15
libscratchcpp::Costume
The Costume class represents a Scratch costume.
Definition
costume.h:17
libscratchcpp::Drawable::Drawable
Drawable()
Definition
drawable.cpp:10
libscratchcpp::IEngine
The IEngine interface provides an API for running Scratch projects.
Definition
iengine.h:41
libscratchcpp::IGraphicsEffect
The IGraphicsEffects class is an interface for custom graphics effects.
Definition
igraphicseffect.h:14
libscratchcpp::List
The List class represents a Scratch list.
Definition
list.h:27
libscratchcpp::Rect
Definition
rect.h:15
libscratchcpp::Sound
The Sound class represents a Scratch sound.
Definition
sound.h:17
libscratchcpp::Sound::Effect
Effect
Definition
sound.h:20
libscratchcpp::Sprite
The Sprite class represents a Scratch sprite.
Definition
sprite.h:18
libscratchcpp::Target::touchingClones
virtual bool touchingClones(const std::vector< Sprite * > &clones) const
Definition
target.h:118
libscratchcpp::Target::Target
Target(const Target &)=delete
libscratchcpp::Target::Target
Target()
Definition
target.cpp:26
libscratchcpp::Target::isStage
virtual bool isStage() const
Definition
target.h:37
libscratchcpp::Target::isTarget
bool isTarget() const override final
Definition
target.cpp:43
libscratchcpp::Target::dataSource
virtual Target * dataSource() const
Definition
target.h:115
libscratchcpp::TextBubble
The TextBubble class represents a text bubble created using say or think block.
Definition
textbubble.h:16
libscratchcpp::Variable
The Variable class represents a Scratch variable.
Definition
variable.h:18
drawable.h
LIBSCRATCHCPP_EXPORT
#define LIBSCRATCHCPP_EXPORT
Definition
global.h:17
libscratchcpp
The main namespace of the library.
Definition
asset.h:10
libscratchcpp::Rgb
unsigned int Rgb
Definition
value_functions.h:11
rect.h
sound.h
libscratchcpp::ValueData
The ValueData struct holds the data of Value. It's used in compiled Scratch code for better performan...
Definition
valuedata.h:26
value_functions.h
include
scratchcpp
target.h
Generated by
1.17.0