Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. 知识库
  3. 小教程
  4. 二维 - 可持续目标3 - 卡路里计算机(难度:2)

二维 - 可持续目标3 - 卡路里计算机(难度:2)

Scheduled Pinned Locked Moved 小教程
1 Posts 1 Posters 819 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CreatiCode TA 2
    wrote on last edited by admin
    #1

     

    覆盖的关键课题

    • 设置或改变角色大小
    • 造型上色
    • 使用变量

     
     

    介绍

    可持续发展目标是联合国在2015年认证的17个目标。它们是每个人都需要共同努力的待办目标。

    这个小教程是关于我们吃的食物的卡路里,这和第三个目标“良好健康和福祉”有关。

    用户可以点击他们吃过的不同种类的食物,而卡路里的总和会被自动计算。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2c3af0eb-9fe1-4b31-a47c-b0e5d6c47ec2.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 1 - 准备一个新的项目

    请创建一个新的项目并移除里面的两个角色。

    选择一个简单的背景图像,比如说“蓝天2”:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/730bb9e5-ffbf-49b6-a0a1-ca802e90a2b4.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 2 - 添加一个苹果角色以及一个“苹果”变量

    现在让我们添加一个苹果角色,并把他放在舞台的左上角。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0c5b1b58-0055-438d-988e-389c767a8e55.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     
    请记得添加一个新的变量 ,并把他命名为“苹果”,并把它移到苹果角色下面。把它的布局改变成“大字显示”以便只有数字数值被展示。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a63fd936-9c6f-48cb-86b8-cdd70f88af73.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 3 - 展示苹果的卡路里

    现在让我们改变造型来展示吃下一个苹果的卡路里,大约数值为80。你可以使用“T”工具来把文字添加到苹果角色的造型,并使用箭头工具来移动和调整字体大小。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/e7a8e91c-d08e-4e3c-a4c1-26fb67eaed4b.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    步骤 4 - 点击动画

    用户可以点击苹果来把它添加到当天吃的食物列表。我们可以简单地添加一个动画来让用户知道他已经正确地点击了。

    转换到“代码”页面,并添加这些编程积木。这些编程积木会在用户点击苹果角色时被运行,然后把苹果的大小减小到原有大小的80%。在等待非常短的时间(100毫秒)后,我们把它的大小设置回100%。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/579e71b0-3f1b-4222-aab2-331a856d4c7d.png" width="300" style="">

    这是程序运行过后的结果:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c4a0b7e9-2633-4d14-9d61-30829a7cd136.gif" width="100" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    步骤 5 - 更新“苹果”变量

    当用户点击苹果之后,我们会把“苹果”变量添加1,以便它会展示总共被添加的苹果数量:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ae8596d1-6a24-49c0-a6ed-190644430651.png" width="300" style="">
     

    无论如何,我们也需要允许用户重重新开始计算。我们可以通过点击绿色旗帜时把“苹果”变量设置成0来做到。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1eb19c73-d172-41df-8221-9a29021aa1e6.png" width="250" style="">
     

    现在,苹果变量正在运行良好:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/833f63ba-af0e-4315-9b55-f9591fd38fdb.gif" width="200" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 5 - 展示总共卡路里的“总数”变量

    我们也会需要计算卡路里总数。请添加一个新的名为“总数”的变量,并把它展示在舞台的底端。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2c613f50-b2cc-4af5-9202-e280c14b93ab.png" width="480" style="border-radius: 5px; border: 1px solid #29622d;">
     

     
     

    步骤 6 - 更新“总数”变量

    我们用来更新“总数”变量的方法跟我们如何更新“苹果”变量很相似。

    • 每当用户点击苹果角色时,我们会把苹果的80卡路里添加到总数。
    • 每当绿色旗帜被点击时,我们把总数重新设置成0。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c94dd97b-4db1-43bf-907f-599e5a23e085.png" width="700" style="">
     

    现在,每当我们添加更多苹果时,总数会被正确地更新:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4b2f42ea-21d2-4308-b2fd-6e32e2a8008f.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">
     

     
     

    步骤 7 - 添加一个甜甜圈角色

    现在让我们添加一个角色,作为甜甜圈。因为我们要重新使用苹果角色的代码,我们有两个选择:

    • 我们可以复制苹果角色,并把它的造型换成一个甜甜圈;
    • 我们可以添加一个新的甜甜圈造型,并从苹果造型复制代码。

    让我们使用第一个方法,右键点击苹果角色来复制他,并把新的角色命名为“甜甜圈”:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d07cfc24-b1d2-4beb-8300-0a4006e5aa85.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">
    接下来,转换到它的“造型”页面,并添加“甜甜圈”造型:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/54d39d1b-e528-4cf3-a61e-67214c0bb6e9.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

    最后,添加字体来展示甜甜圈的卡路里,它的卡路里大概是200。你可以选择一个不一样的颜色来让他更容易阅读。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6a0e8746-9169-489a-b38f-719de65eb483.png" width="250" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 7 - 添加“甜甜圈”变量

    我们需要一个新的名为“甜甜圈“的变量来追踪有多少个甜甜圈被吃掉了,并把它放置在甜甜圈角色下方:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/281541a4-d5fe-4e76-a65a-9b72e482a003.png" width="250" style="border-radius: 5px; border: 1px solid #29622d;">
     

    现在请改变甜甜圈角色的代码,用”甜甜圈“变量来取代”苹果“变量。并且,”总数“应该在我们每次点击甜甜圈角色时增加200。

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/8e9c1adf-664c-4aa1-a491-7b3177e45f9d.png" width="600" style="">
     

    现在我们的计算机将能够计算两个角色的卡路里:

     
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/47ec1d79-c568-4cb0-b177-50b16ac66dfc.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">
     

     

    步骤 8 - 添加更多食物

    请重复以上步骤来添加更多食物。这是一些例子:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b9fb72ed-bd14-428e-980a-395df0d3a1ec.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

    如果你正在以团队形式创建程序,你们每个人都可以尝试创建一些食物种类,然后你们可以通过导出和导入角色来合并你们的程序。

     
     

    创意点子

    你可以有很多方法和使用你自己的创意来延展这个程序。这是一些例子:

    • 添加练习: 你可以添加一些额外的角色来代表一些不一样形式的练习。举个例子,添加一个奔跑的角色,每当用户点击角色时,这意味着用户跑步一分钟,我们可以减少10个卡路里的卡路里总数。

    • 多个页数: 我们可以添加两个按钮,一个”上一页“和一个”下一页“,这样我们就可以在不同的页面展示不一样的食物,这会允许我们展示更多的食物选择。

    1 Reply Last reply
    0
    • C CreatiCode Teacher moved this topic from Draft on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode