From Test-Scratch-Wiki
![]() |
Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. |
![]() |
This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines. Reason: Too short, little explanation. |
![]() | This tutorial is recommended for a bit more experienced Scratcher due to its intricacy. |
什么是 3D 环境?
A 3D 环境(3D environment) is a place that involves the common X and Y axes, as well as the additional Z axis. The Z axis is a Cartesian coordinate, much like the X and Y axes, but the Z axis usually is the axis for depth. In real life, the Z axis exists, but in Scratch, it does not. We can incorporate size and movement that causes an illusion of depth.
用角色尺寸来制造 3D 效果的示例
This 程式 uses 角色 and size change for depth perception:
當 @greenflag 被點擊 變數 [scroll z v] 設為 [60] 變數 [scroll y v] 設為 [0] 變數 [scroll x v] 設為 [-30] 重複無限次 尺寸設為 ((scroll z) + ((40) * (0))) % x 設為 ((scroll x) + ((480) * (0))) y 設為 ((scroll y) + ((360) * (0))) 如果 <[向上 v] 鍵被按下?> 那麼 變數 [scroll z v] 改變 ((size) / (45)) 變數 [scroll x v] 改變 ((x 座标) / (55)) end 如果 <[向下 v] 鍵被按下?> 那麼 變數 [scroll z v] 改變 ((size) / (-45)) 變數 [scroll x v] 改變 ((x 座标) / (-55)) end 如果 <[向左 v] 鍵被按下?> 那麼 變數 [scroll x v] 改變 ((size) / (55)) end 如果 <[向右 v] 鍵被按下?> 那麼 變數 [scroll x v] 改變 ((size) / (-55)) end 如果 <<(scroll z) < [20]> 或 <(scroll z) > [217]>> 那麼 隱藏 顯示 end end
The "scroll x" and "scroll y" variables' value can be changed so the sprite's position can be changed. The "scroll z" variable is rather special. It does not change the sprite's position, but it changes The size of the sprite.
This method of 3D scripting is very rudimentary, and it does not involve any collision detection, and it would not apply to a moving object.
This is one of the ways you can make the illusion of 3D. Scratch doesn't allow you to make three dimensional games, but it allows you to make the illusion of one. The X axis is the 角色 position from left to right. The Y axis is the position from top to bottom, and the Z axis is the 角色 size, allowing you to make the sprite small or large. As said in the beginning of this article, we can always incorporate size and movement to create the 3D illusion. If you stroll down a street, you will notice that the farther the things are, the smaller they look. If you put this same principle in video games, you will get a 3D effect. A Raycaster is a more efficient way of 3D in Scratch.
使用画笔和图层的示例
This is a slightly more efficient way of making a 3D illusion. This technique uses layering and stamping. Here is the 程式:
當 @greenflag 被點擊 重複無限次 筆跡清除 定位到 x: (0) y: (0) 蓋章 y 改變 (2) 蓋章 y 改變 (2) 蓋章 y 改變 (2) 蓋章 y 改變 (2) 蓋章 y 改變 (2) 蓋章 y 改變 (2) 蓋章 end 當 @greenflag 被點擊 重複無限次 面朝 [滑鼠游標 v] 向 end
This method does not use size to create the 3D effect. It changes the position of the sprite and 盖章 the sprite on the background. This makes several copies of the same sprite, in different positions. This creates a 3D effect.