<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[名称和角色物体]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="预备知识"></a>预备知识</h2>
<ul>
<li><a href="/topic/11/loading-an-avatar-into-a-scene">在场景中载入角色</a></li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="介绍"></a>介绍</h2>
<p dir="auto">在二维程序中，每个精灵都对应着舞台上的一个物体（一个图像）。但在三维程序中，我们很大可能会创建多过一个物体，比如3个角色或100个盒子。因此，要同时处理多个物体，你需要<strong>在创建物体时为物体指定名称</strong>，一边你可以在过后的程序中<strong>利用名称来代表该物体</strong>。</p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="为物体指定名称"></a>为物体指定名称</h2>
<p dir="auto"> <br />
<img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/266e75fb-65e8-404b-9afb-e1ce8f4f868e.png" width="500" /></p>
<ul>
<li><strong>名称</strong>: 这个物体的名字。需要注意的是，除了这个编程积木之外，还有很多编程积木会允许你指定名称。所有允许你命名的编程积木末端都会有个 <strong>“名为”</strong> 输入框。如果你让“名为”输入框保持空白，那么新创建的物体就会被三维引擎赋予一个<strong>随机又独特的名字</strong>， 比如<strong>ID234234239</strong>。</li>
</ul>
<p dir="auto"> </p>
<h3><a class="anchor-offset" name="特点"></a>特点</h3>
<p dir="auto">当你指定一个名称时，新添加的物体就会拥有那个名称。你可以通过查看<strong>三维场景视窗下方的“物体”列表</strong>来确认，因为新物体的名称会出现在那个列表里。如果你让“名为”输入框保持空白，那么一个随即名称就会出现在该名称列表里。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/113ac069-beea-4079-9e30-f204e4f0cfc8.gif" width="1000" style="border-radius:5px;border:1px solid #29622d" /><br />
 <br />
假设你添加了两个名称不一样的老虎角色，比如”老虎1“和“老虎2”，那么两个老虎角色的名称都会出现在物体列表：</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/8451d1ec-e335-4327-b2b4-fa993d06c614.gif" width="1000" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
当你用一个<strong>已经被别的物体使用的名称</strong>在场景中为物体指定名称时，特殊情况就会出现。在这样的情况中，三维引擎将会在场景中<strong>在还没有添加新物体前移除另一个物体</strong>，因为一个名称只可以被一个物体使用。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/81f44cf0-1cb5-4cc7-9472-142461c5140e.gif" width="1000" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="最新添加的物体"></a>最新添加的物体</h2>
<p dir="auto">假设在一个场景中有两个角色，一只老虎和一只牛。当你运行”移动50步“的指令时，两个角色中的哪一个会接收并运行你的指令？</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b45fa56e-61f8-4788-8cb3-6a8b7dd0fa73.gif" width="1000" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
为了避免卡通老虎和卡通牛之间的纷争，我们用一个简单的规则，<strong>最新添加的物体</strong>。这个规则意味着哪个物体在一个指令之前被添加，那个物体就会接收该条指令。举个例子，在这个程序里面，卡通牛是在“移动”指令之前被添加的，所以卡通牛会向前移动。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4fdb3dd6-364d-43ea-aa27-2cc281b3fdca.gif" width="800" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="角色物体"></a>角色物体</h2>
<p dir="auto">我们也可以利用物体名称把指令发送给特定的物体。我们只需要把其中一个物体挑选为<strong>活跃物体</strong>，以便所有的指令都被那个物体接收。因为每一个角色都可以拥有这样一个活跃物体，我们把它称之为<strong>角色物体</strong>。换句话说，<strong>一个角色物体是从角色中接收指令的物体</strong>。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/20309833-e31e-4080-b359-1f2a797e39ec.png" width="500" /><br />
 <br />
我们可以利用以上程序积木通过一个物体的姓名来选择物体作为角色物体。需要注明的是，该物体的姓名需要是一个你已经用来创建一些物体的现有姓名。现在回看我们的例子，我们可以利用卡通老虎的名字“托尼”，来把卡通老虎选为角色物体，然后卡通老虎将会执行移动指令。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2c7ca929-1402-4d8f-b4af-ca5799f37601.gif" width="900" /><br />
 <br />
当一个新物体被加入到场景中，他就会自动被选为“角色物体”。这个就是***“最新添加的物体”**规则的运行方式。<strong>现有角色物体</strong>的姓名会在三维场景视窗中下的物体列表被展示。你可以一步一步运行以下的程序来检验角色物体改变的过程：</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/awsuploads/947564/images/9249229/stepbystep.gif" width="900" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="利用名称移除物体"></a>利用名称移除物体</h2>
<p dir="auto">你可以利用这个编程积木，提供物体名称以便可以移除它。如果没有任何名称被提供，那么现有的角色物体就会被移除。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/229e4626-da42-4df4-906d-d25c93d5c8b7.png" width="300" /><br />
 <br />
举个例子，这个程序添加了一个名称为"r"的替身，那么我们可以利用这个名称来移除它。</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ea95e294-b326-4882-a034-61b376432525.gif" width="800" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="了解更多"></a>了解更多</h2>
<ul>
<li><a href="/topic/20/3d-coordinates-and-positions">三维坐标和位置</a></li>
</ul>
]]></description><link>https://forum.creaticode.com/topic/354/名称和角色物体</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 09:13:59 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/354.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Jul 2022 07:12:27 GMT</pubDate><ttl>60</ttl></channel></rss>