Show last authors
1 (% class="wikigeneratedid" %)
2 Motion Bricks are used to set the position, direction, movement, and physics of objects. Position is set with a coordinate system similar to the Cartesian Plane, wherein the X and Y axes run along the center of the screen. Direction is set with the specified amount of degrees. Movement is set using steps/second, where steps refers to the distance traveled by a sprite along the X or Y axes. The physics engine, meanwhile, applies friction, gravity, and varying motion styles to different objects.
3
4 ----
5
6 {{id name="PlaceAtBrick"/}}
7
8 ===== **Place at X: (100) Y: (200)** =====
9
10 ----
11
12 [[image:Brick_place_at.png||alt="~"Place at~"  brick as shown in Pocket Code" width="320" height="84"]]
13
14 Places the sprite at the specified X and Y coordinates.
15
16 {{html}}
17 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/IxfZ_UTXAtU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
18 {{/html}}
19
20 {{id name="SetXBrick"/}}
21
22 ===== **Set X to (100)** =====
23
24 ----
25
26 [[image:Brick_set_x.png||alt="~"Set X to~" brick as seen in Pocket Code" width="320" height="62"]]
27
28 Places the sprite at the specified X coordinate.
29
30 {{html}}
31 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/UuybVxOZ2Cg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
32 {{/html}}
33
34 {{id name="SetYBrick"/}}
35
36 ===== **Set Y to (200)** =====
37
38 ----
39
40 [[image:Brick_set_y.png||alt="~"Set Y to~" brick as seen in Pocket Code" width="320" height="62"]]
41
42 Places the sprite at the specified Y coordinate.
43
44 {{html}}
45 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/cManXQXoELk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
46 {{/html}}
47
48 {{id name="ChangeXByNBrick"/}}
49
50 ===== **Change X by (10)** =====
51
52 ----
53
54 [[image:Brick_change_x.png||alt="~"Change X by~" brick as seen in Pocket Code" width="320" height="62"]]
55
56 Changes the sprite's X coordinate by the given increment. This is equivalent to adding the increment to the current X coordinate. It is possible to decrease the X coordinate by using a negative increment as input.
57
58 {{html}}
59 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/O2La517s2Jw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
60 {{/html}}
61
62 {{id name="ChangeYByNBrick"/}}
63
64 ===== **Change Y by (10)** =====
65
66 ----
67
68 [[image:Brick_change_y.png||alt="~"Change Y by~" brick as seen in Pocket Code" width="320" height="62"]]
69
70 Changes the sprite's Y coordinate by the given increment. This is equivalent to adding the increment to the current Y coordinate. It is possible to decrease the Y coordinate by using a negative increment as input.
71
72 {{html}}
73 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/eOBXo4wSazw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
74 {{/html}}
75
76 ===== =====
77
78 {{id name="GoToBrick"/}}
79
80 ===== **Go to (Touch position/Random position/Object)** =====
81
82 ----
83
84 The sprite goes either to the touch position, to a random position, or to the position of another object. These parameters are chosen from a drop-down list that appears when the brick is tapped.
85
86 [[image:2018_11_06_104247.png||alt="~"Go to touch position~" brick" width="320" height="94"]]
87
88 When using the touch position parameter, the brick checks if the screen is currently being touched (if screen_is_touched is true). If it is, the position of the sprite is centered at the touch position. If not, the position of the sprite remains at its last position.
89
90 [[image:motion_go_to_random.png||alt="~"Go to random position~" brick as seen in Pocket Code" width="320" height="98"]]
91
92 When using the random position parameter, the position of the sprite is centered at any random on-screen X and Y coordinates.
93
94 [[image:2018_11_06_104251.png||alt="~"Go to object~" brick" width="320" height="92"]]
95
96 When using the object parameter, the screen centers the sprite at the selected object. In Pocket Code, the name of the objects to be chosen from is shown in the drop-down list.
97
98 {{id name="WhenBounceOffBrick"/}}
99
100 ===== **When you bounce off** =====
101
102 ----
103
104 ===== [[image:Screenshot_20190828-162936_Pocket Code.jpg||width="322" height="114"]] =====
105
106 Runs the script when the object bounce off any edge, actor or object
107
108 {{id name="IfOnEdgeBounceBrick"/}}
109
110 ===== **If on edge, bounce** =====
111
112 ----
113
114 [[image:Brick_if_edge.png||alt="~"If on edge~" brick as seen in Pocket Code" width="320" height="60"]]
115
116 Checks if the sprite is touching the edge of the screen and bounces off the edge if it is.
117
118 {{html}}
119 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/-59P1xytvnw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
120 {{/html}}
121
122 {{id name="MoveNStepsBrick"/}}
123
124 ===== **Move (10) steps** =====
125
126 ----
127
128 [[image:Brick_move.png||alt="~"Move steps~" brick as seen in Pocket Code" width="320" height="62"]]
129
130 Moves the sprite a certain number of steps.
131
132 {{html}}
133 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/9BsaL0QDrWM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
134 {{/html}}
135
136 {{id name="TurnLeftBrick"/}}
137
138 ===== **Turn left (15) degrees** =====
139
140 ----
141
142 [[image:turn left.jpg||width="316" height="63"]]
143
144 Rotates the sprite counter-clockwise by the specified amount of degrees.
145
146 {{html}}
147 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/PVbXSCCT9vo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
148 {{/html}}
149
150 {{id name="TurnRightBrick"/}}
151
152 ===== **Turn right (15) degrees** =====
153
154 ----
155
156 [[image:turn rigth.jpg||width="319" height="63"]]
157
158 Rotates the sprite clockwise by the specified amount of degrees.
159
160 {{html}}
161 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/ZEfGib7OFpg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
162 {{/html}}
163
164 {{id name="PointInDirectionBrick"/}}
165
166 ===== **Point in direction (90) degrees** =====
167
168 ----
169
170 [[image:point in direction.jpg||width="322" height="63"]]
171
172 Sets the direction of the sprite to the set number of degrees. Unlike "Turn left" or "Turn right," the sprite is set to the specified direction regardless of its previous orientation.
173
174 When using this brick, 90//° //is used to refer to the default, or upright, position. Increasing this value rotates the sprite clockwise, while decreasing this value rotates the sprite counter-clockwise.
175
176 {{html}}
177 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/9T3tmYpIBpI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
178 {{/html}}
179
180 {{id name="PointToBrick"/}}
181
182 ===== **Point towards (Object)** =====
183
184 ----
185
186 [[image:Brick_point_towards.png||alt="~"Point towards~" brick as seen in Pocket Code" width="320" height="84"]]
187
188 Sets the direction of the sprite to point to the selected object. The chosen object can be changed from a drop-down list that appears when the brick is tapped.
189
190 {{html}}
191 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/3EHcMaeI828" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
192 {{/html}}
193
194 {{id name="SetRotationStyleBrick"/}}
195
196 ===== **Set rotation style (left-right only/all-around/don't rotate)** =====
197
198 ----
199
200 Sets the restrictions to rotating the sprite. The rotation style of the chosen object can be changed from a drop-down list that appears when the brick is tapped.
201
202 [[image:set_rotation_left-right.png||alt="~"Set rotation style to left-right only~" brick" width="320" height="86"]]
203
204 Left-right only restricts rotation to flipping the sprite horizontally. It may be used as animation for still sprites or in 2D games.
205
206 [[image:set_rotation_all-around.png||alt="~"Set rotation style to all around~" brick" width="320" height="92"]]
207
208 All-around allows the sprite to rotate normally in all directions. Since the default rotation style without using this brick is set to all around, this brick is best used when returning the rotation style to normal after having changed it.
209
210 [[image:set_rotation_don't_rotate.png||alt="~"Set rotation style to don't rotate~" brick" width="320" height="96"]]
211
212 Don't rotate negates the effects of all bricks which alters the sprite's movement. This may be used when adding exceptions to rotation of a sprite.
213
214 {{id name="GlideToBrick"/}}
215
216 ===== **Glide (1) second to X: (100) Y: (200)** =====
217
218 ----
219
220 [[image:Brick_glide.png||alt="~"Glide to~" brick as shown in Pocket Code" width="320" height="111"]]
221
222 Moves the sprite to the specified X and Y coordinates within the input time. The higher the input time, the slower the speed of movement. The lower the input time, the faster the speed of movement.
223
224 {{html}}
225 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/-xtmZcXEosE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
226 {{/html}}
227
228 {{id name="GoNStepsBackBrick"/}}
229
230 ===== **Go back (1) layer** =====
231
232 ----
233
234 [[image:Brick_go_back_layer.png||alt="~"Go back layer~" brick as seen in Pocket Code" width="320" height="62"]]
235
236 Moves the sprite backwards a specified number of layers in the layer stack. The higher the input number of layers, the more likely other sprites will overlap the object.
237
238 {{html}}
239 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/NLB-oDLUyo8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
240 {{/html}}
241
242 {{id name="ComeToFrontBrick"/}}
243
244 ===== **Go to front** =====
245
246 ----
247
248 [[image:Brick_go_front.png||alt="~"Go to front~" brick as seen in Pocket Code" width="320" height="62"]]
249
250 Moves the sprite to the uppermost layer in the layer stack. The sprite will overlap all other sprites when running the brick.
251
252 {{html}}
253 <iframe max-width="100%" height="auto" src="https://www.youtube.com/embed/GTSfosDgTdM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
254 {{/html}}
255
256 {{id name="Vibration brick"/}}
257
258 ===== **Vibrate for (1) second** =====
259
260 ----
261
262 [[image:2018_11_06_104411.png||alt="~"Vibrate for seconds~"" width="320" height="71"]]
263
264 Makes the user's device vibrate for the specified number of seconds. This is often used as an effect for games or as a notification to the user.
265
266 {{id name="SetPhysicsObjectTypeBrick"/}}
267
268 ===== **Set your motion type to** =====
269
270 ----
271
272 Sets the motion type of the sprite, which can be changed from a drop-down list that appears when the brick is tapped.
273
274 [[image:Screenshot_20190828-172223_Pocket Code.jpg||width="314" height="158"]]
275
276 The "moving and bouncing under gravity" motion type allows the object to be influenced by physics, gravity, collisions, etc. For example, a ping-pong ball with this motion type may collide with other dynamic and fixed sprites.
277
278 The "not moving under gravity, but others bounce off" motion type sets the object to a "static" sprite, so that is not influenced by physics, gravity, collisions, etc. For example, the floor of an indestructible wall with this motion type collides with dynamic sprites only.
279
280 The "not moving or bouncing under gravity" motion type sets disables physics features for the sprite. For example, the default non-physics sprites have this motion type, such as backgrounds, which do not collide with any other physics objects.
281
282 {{id name="SetVelocityBrick"/}}
283
284 ===== **Set velocity to X: (0) Y: (0) steps/second** =====
285
286 ----
287
288 [[image:Brick_set-velocity-to.png||alt="~"Set velocity to~" brick" width="320" height="92"]]
289
290 Sets the sprite's movement along the X and Y axes per second. Higher values correspond to higher velocity. Likewise, lower values correspond to lower velocity.
291
292 {{id name="TurnLeftSpeedBrick"/}}
293
294 ===== **Spin left (15) degrees/second** =====
295
296 ----
297
298 [[image:Screenshot_20190828-172414_Pocket Code.jpg||width="322" height="62"]]
299
300 Rotates the sprite counter-clockwise at a given amount of degrees per second.
301
302 {{id name="TurnRightSpeedBrick"/}}
303
304 ===== **Spin right (15) degrees/second** =====
305
306 ----
307
308 [[image:Screenshot_20190828-172435_Pocket Code.jpg||width="318" height="62"]]
309
310 Rotates the sprite clockwise at a given amount of degrees per second.
311
312 {{id name="SetGravityBrick"/}}
313
314 ===== **Set gravity for all actors and X: (0) Y: (-10) steps/second&sup2;** =====
315
316 ----
317
318 [[image:Screenshot_20190828-172455_Pocket Code.jpg||width="320" height="105"]]
319
320 Sets the gravity which affects all dynamic physics objects along the X and Y axes. Both positive and negative values are allowed for gravity on both X and Y axes.
321
322 {{id name="SetMassBrick"/}}
323
324 ===== **Set mass to (1.0) kilogram** =====
325
326 ----
327
328 [[image:2018_11_06_105134.png||alt="~"Set mass to kilograms~" brick" width="320" height="80"]]
329
330 Sets an object's mass to a value of 0 or above. Setting an object's mass will not affect the speed of movement due to gravity.
331
332 {{id name="SetBounceBrick"/}}
333
334 ===== **Set bounce factor to (80%)** =====
335
336 ----
337
338 [[image:2018_11_06_105240.png||alt="~"Set bounce factor~" brick" width="320" height="86"]]
339
340 Sets how much of an object‘s velocity is lost (or gained) upon collision with another physics object to value of 0% or above. This also determines how violently objects bounce off of each other after collision. If both colliding objects have a bounce factor of 0, they do not bounce off each other at all upon collision.
341
342 {{id name="SetFrictionBrick"/}}
343
344 ===== **Set friction to (20%)** =====
345
346 ----
347
348 [[image:2018_11_06_105352.png||alt="~"Set friction to~" brick" width="320" height="71"]]
349
350 Sets friction to a value of 0 or above, which determines how fast/easily physics objects can glide along one another. The higher the objects’ friction values, the slower they will glide on each other due to contact.