<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Separating_Clone_and_Sprite_Triggers</id>
	<title>Separating Clone and Sprite Triggers - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Separating_Clone_and_Sprite_Triggers"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;action=history"/>
	<updated>2026-05-19T08:30:05Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=2461&amp;oldid=prev</id>
		<title>Patarakin в 08:12, 29 августа 2022</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=2461&amp;oldid=prev"/>
		<updated>2022-08-29T08:12:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 11:12, 29 августа 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Строка 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:Clones.png|thumb|224px|The hierarchy of a sprite and its clones.]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;With the introduction of [[cloning]] in [[Scratch 2.0]], [[project]]s have many efficient capabilities to perform tasks without creating an extensive number of [[sprite]]s. Clones are instances of sprites, meaning they inherit the properties of the sprite but are separate objects. Clones commonly may have a slightly different task to perform than the parent sprite, but one barrier is that both clones and sprites respond to almost all of the [[Event Blocks|event blocks]] (triggers). Therefore, a trigger specifically designed for a sprite will also be run by a clone when signaled.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;With the introduction of [[cloning]] in [[Scratch 2.0]], [[project]]s have many efficient capabilities to perform tasks without creating an extensive number of [[sprite]]s. Clones are instances of sprites, meaning they inherit the properties of the sprite but are separate objects. Clones commonly may have a slightly different task to perform than the parent sprite, but one barrier is that both clones and sprites respond to almost all of the [[Event Blocks|event blocks]] (triggers). Therefore, a trigger specifically designed for a sprite will also be run by a clone when signaled.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Строка 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 64:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Cloning]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[ja:クローンとトリガースプライトを分離する]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=1700&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=1700&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:14Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 11:33, 21 июля 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=1699&amp;oldid=prev</id>
		<title>scratch&gt;SonicFanX123 321 в 11:39, 2 августа 2021</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Separating_Clone_and_Sprite_Triggers&amp;diff=1699&amp;oldid=prev"/>
		<updated>2021-08-02T11:39:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[File:Clones.png|thumb|224px|The hierarchy of a sprite and its clones.]]&lt;br /&gt;
With the introduction of [[cloning]] in [[Scratch 2.0]], [[project]]s have many efficient capabilities to perform tasks without creating an extensive number of [[sprite]]s. Clones are instances of sprites, meaning they inherit the properties of the sprite but are separate objects. Clones commonly may have a slightly different task to perform than the parent sprite, but one barrier is that both clones and sprites respond to almost all of the [[Event Blocks|event blocks]] (triggers). Therefore, a trigger specifically designed for a sprite will also be run by a clone when signaled.&lt;br /&gt;
&lt;br /&gt;
== Concept ==&lt;br /&gt;
One way to understand the concept is with the following simple [[script]]:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when this sprite clicked&lt;br /&gt;
go to x:(0) y:(pick random (-100) to (100))&lt;br /&gt;
repeat (10)&lt;br /&gt;
change x by (3)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
Contrary to its name, if a clone of the sprite containing the above script was to be clicked, the clone itself would perform the script. If only the sprite and &amp;#039;&amp;#039;not&amp;#039;&amp;#039; its clones should respond to the script, customize which triggers are run by what class (i.e. parent sprite or child clone) through the use of a [[Variable#Local Variables|local variable]]. If a local variable is not used, all clones will share the same variable.&lt;br /&gt;
[[File:Private var creation.png|thumb|250px|Creating a local variable.]]&lt;br /&gt;
Local [[variable]]s store values for individual sprites and clones, although they have the same name. For example, three clones can have a variable named &amp;quot;x velocity&amp;quot;, but each clone can have its own individual value of its variable. In a similar way, a sprite can have a variable set to a particular [[string]] while every clone has it set to a different value. This concept of different variable values between classes allows one to choose which scripts are run by the parent sprite or child clones.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
When the [[Green Flag|green flag]] is clicked, all clones are immediately deleted but the parent sprite still exists. This is the correct time to set the sprite&amp;#039;s variable to an indication of its class (position on the hierarchy).&lt;br /&gt;
&lt;br /&gt;
=== Making clones behave differently to the parent sprite ===&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set [instance v] to [sprite] //&amp;quot;instance&amp;quot; must be a private variable&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This small bit of data saved in the variable &amp;quot;instance&amp;quot; simply shows that the sprite is a sprite. &amp;quot;Instance&amp;quot; must be a [[private variable|Private Variable]] or else it will not work. Next, a script must be designated for assigning all clones a variable value that shows they are clones. The following script can accomplish this:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I start as a clone //a sprite cannot run this script, only clones&lt;br /&gt;
set [instance v] to [clone]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
The above script will &amp;#039;&amp;#039;not&amp;#039;&amp;#039; change the sprite&amp;#039;s variable. Instead, each individual clone will have its own variable. Once this is done, the variable in conjunction with an [[If () Then (block)|if statement]] can properly designate triggers to only run for the sprite or its clones.&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [fadeAway v] //This script only works for clones&lt;br /&gt;
if &amp;lt;(instance) = [clone]&amp;gt; then&lt;br /&gt;
repeat (10)&lt;br /&gt;
change [ghost v] effect by (10)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
The above script will only work for the clones, because the sprite&amp;#039;s variable is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; set to &amp;quot;clone&amp;quot;, and the sprite will not execute the blocks inside the statement. This variable method is an efficient way for debugging projects in which clones are causing trouble.&lt;br /&gt;
&lt;br /&gt;
=== Making clones behave differently from each other ===&lt;br /&gt;
The following example shows how multiple clone types can be managed in a single sprite&amp;#039;s scripts. Note that a value is assigned to the private variable &amp;quot;type&amp;quot; &amp;#039;&amp;#039;before&amp;#039;&amp;#039; each clone (or set of similar clones) is generated. If the parent sprite is to ignore a broadcast, its own unique value of &amp;quot;type&amp;quot; should be set &amp;#039;&amp;#039;after&amp;#039;&amp;#039; the clones have been generated but &amp;#039;&amp;#039;before&amp;#039;&amp;#039; the broadcast is expected.&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when green flag clicked&lt;br /&gt;
set [type v] to [ghost] //&amp;quot;type&amp;quot; must be a private variable.&lt;br /&gt;
create clone of (myself v)&lt;br /&gt;
set [type v] to [egon]&lt;br /&gt;
create clone of (myself v)&lt;br /&gt;
set [type v] to [parent]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [send in the ghosts v] //This script only works for clones...&lt;br /&gt;
if &amp;lt;(type) = [ghost]&amp;gt; then //...but can differentiate between them.&lt;br /&gt;
start sound (spooky moan v)&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(type) = [egon]&amp;gt; then&lt;br /&gt;
say [Don&amp;#039;t cross the streams!]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
The value of the private variable &amp;quot;type&amp;quot; is inherited by each clone from the parent sprite, which ignores the broadcast because its own value of &amp;quot;type&amp;quot; is different. This technique allows many different clone types to behave in unique ways.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Cloning]]&lt;br /&gt;
* [[Private Variables]]&lt;br /&gt;
* [[Sprite]]&lt;br /&gt;
* [[Variable]]s&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
[[Category:Cloning]]&lt;br /&gt;
[[ja:クローンとトリガースプライトを分離する]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;SonicFanX123 321</name></author>
	</entry>
</feed>