<?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=Scrolling_%28creating_a_scroller%29</id>
	<title>Scrolling (creating a scroller) - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Scrolling_%28creating_a_scroller%29"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Scrolling_(creating_a_scroller)&amp;action=history"/>
	<updated>2026-04-07T12:31:28Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Scrolling_(creating_a_scroller)&amp;diff=1712&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Scrolling_(creating_a_scroller)&amp;diff=1712&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=Scrolling_(creating_a_scroller)&amp;diff=1711&amp;oldid=prev</id>
		<title>scratch&gt;TenType: Removed big gap at the top of the page</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Scrolling_(creating_a_scroller)&amp;diff=1711&amp;oldid=prev"/>
		<updated>2021-07-12T18:21:39Z</updated>

		<summary type="html">&lt;p&gt;Removed big gap at the top of the page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{April Fools}}{{stub|date=June 2018}}{{merge|Scrolling Platformer Tutorial|date=October 2018}}&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;scroller&amp;#039;&amp;#039;&amp;#039; is a type of [[project]] that makes the background &amp;quot;scroll&amp;quot;, or move out of the screen to make it feel like the player is moving.&lt;br /&gt;
{{note|This tutorial specifically deals only with x scrolling, but the concepts can be used for y scrolling.}}&lt;br /&gt;
&lt;br /&gt;
The end product of this tutorial is a simple project where every time an object touches the player, it moves away from the player some more.&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
&lt;br /&gt;
=== Sprites ===&lt;br /&gt;
There will be four sprites used:&lt;br /&gt;
* Player: This is the sprite that the user controls.&lt;br /&gt;
* Background: This is the scrolling background.&lt;br /&gt;
* Hitbox: This is what sprites that touch the player will actually be touching. It is not shown.&lt;br /&gt;
* Object: The object that is interacting with the player.&lt;br /&gt;
&lt;br /&gt;
=== Costumes ===&lt;br /&gt;
* The player and object can be anything&lt;br /&gt;
* The hitbox should be a rectangle or some shape that covers the place that actually counts as touching the player&lt;br /&gt;
* The background has to fill the entire screen and ideally chain well (i.e. one side of the background should smoothly transition into the other side)&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
* &amp;lt;sb&amp;gt;(scroll x)&amp;lt;/sb&amp;gt;: &amp;quot;for all sprites&amp;quot;, this tracks the virtual x position.&lt;br /&gt;
* &amp;lt;sb&amp;gt;(my x)&amp;lt;/sb&amp;gt;: &amp;quot;for this sprite&amp;quot; on the Object sprite, this controls the object&amp;#039;s virtual x position.&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
&lt;br /&gt;
=== Setup ===&lt;br /&gt;
In the Hitbox sprite, add the following script:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set [ghost v] effect to (99) //not visible to the user, but still not technically hidden&lt;br /&gt;
forever&lt;br /&gt;
  go to (Player v)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will make the hitbox hidden, but other sprites can still check if they are touching it. The hitbox will also move so that it covers the Player correctly.&lt;br /&gt;
&lt;br /&gt;
In the Player sprite, add the following script:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set [scroll x v] to (0) // reset virtual x to 0&lt;br /&gt;
go to x: (0) y: (0) // the sprite itself should never move&lt;br /&gt;
set rotation style [left-right v] // it should point left or right only&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will simply initialize the positions.&lt;br /&gt;
&lt;br /&gt;
In the Background sprite, add the following script:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
go to x: (0) y: (0)&lt;br /&gt;
go to [back v] layer // the background should always be at the back&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will move the background to the center and move it behind all other sprites.&lt;br /&gt;
&lt;br /&gt;
In the Object sprite, add the following script:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set y to (0) // this can be a different value if necessary&lt;br /&gt;
set [my x v] to (100) // this can be customized&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Basic Movement ===&lt;br /&gt;
Expand the script in the Player sprite as follows:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set [scroll x v] to (0)&lt;br /&gt;
go to x: (0) y: (0)&lt;br /&gt;
set rotation style [left-right v]&lt;br /&gt;
forever&lt;br /&gt;
  if &amp;lt;key (right arrow v) pressed?&amp;gt; then&lt;br /&gt;
    change [scroll x v] by (5)&lt;br /&gt;
    point in direction (90)&lt;br /&gt;
  end&lt;br /&gt;
  if &amp;lt;key (left arrow v) pressed?&amp;gt; then&lt;br /&gt;
    change [scroll x v] by (-5)&lt;br /&gt;
    point in direction (-90)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will change the virtual x so that the backgrounds will move.&lt;br /&gt;
&lt;br /&gt;
=== Background Movement ===&lt;br /&gt;
Expand the script in the Background sprite as follows:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
go to x: (0) y: (0)&lt;br /&gt;
go to [back v] layer&lt;br /&gt;
create clone of (myself v)&lt;br /&gt;
forever&lt;br /&gt;
  set x to (() - ((scroll x) mod (480)))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will make the background move so that it appears as if the player was moving.&lt;br /&gt;
&lt;br /&gt;
Add the following new script as well:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I start as a clone&lt;br /&gt;
go to [back v] layer&lt;br /&gt;
forever&lt;br /&gt;
  set x to ((480) - ((scroll x) mod (480)))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will add a copy of the background shifted one Stage width to the right, so that the illusion is not broken by the first copy letting the white Stage through.&lt;br /&gt;
&lt;br /&gt;
=== Object Movement ===&lt;br /&gt;
Expand the Object&amp;#039;s script as follows:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set y to (0)&lt;br /&gt;
set [my x v] to (100)&lt;br /&gt;
forever&lt;br /&gt;
  set x to ((my x) - (scroll x)) // This makes the object appear in the correct position relative to the player&lt;br /&gt;
  if &amp;lt;touching (Hitbox v)?&amp;gt; then&lt;br /&gt;
    change [my x v] by (100) // the scrolling equivalent of &amp;quot;change x by (100)&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
This will make it appear in the correct position relative to the player.&lt;br /&gt;
&lt;br /&gt;
That is all that is necessary. More objects with more complex behavior can be added following the &amp;quot;Object&amp;quot;&amp;#039;s example.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
[[Category:Game Design Tutorials]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;TenType</name></author>
	</entry>
</feed>