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. 自制积木——第2部分

自制积木——第2部分

Scheduled Pinned Locked Moved 二维积木
1 Posts 1 Posters 950 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
    creaticodeteacher2-mail
    wrote on last edited by admin
    #1

     

    先修科目

    • 自制积木——第1部分

     
     

    介绍

    在上一篇知识自制积木——第1部分,大家已经学习了自制积木的基础知识。

    这一篇知识将介绍自制积木的2个高级选项。

     
     

    运行时不刷新屏幕

    “屏幕刷新”也被称为“屏幕更新”,意思就是计算机更新屏幕上显示的东西。通常情况下,计算机需要擦除舞台上原有的所有东西,然后再重新画所有东西。因为这个过程非常之快,所以看起来东西就在舞台上移动。

    比如,我们利用画笔扩展,移动角色即可画出一些阶梯。这需要好几秒钟才能完成,因为每移动一次,计算机就需要擦除舞台上的绘画和球,然后根据更新的球的位置和阶梯重新绘制。另外,舞台下面角色窗格中的信息也会随之更新,例如球的x坐标、y坐标。

     
    假如我们不需要显示球的动画,只需要在舞台上显示最终结果,就可以跳过屏幕刷新,从而使程序运行更快。

    若要这么做,就自制一个积木,然后勾选选项“运行时不刷新屏幕”。

     
    接下来,把绘画所用的全部积木装配到这个新积木的“定义”堆栈。当你再次运行程序,它会立即完成,因为跳过了中间的全部屏幕刷新。只绘制最终结果。

     
    总之,无论是二维项目还是三维项目,如果你想让程序运行更快,不需要显示中间步骤动画,那么自制积木就应当把所有步骤“封装”起来,就勾选“运行时不刷新屏幕”。

     
     

    制作一个返回值的报表积木

    默认情况下,自制积木是“堆栈积木”。你也可以改为“报表积木”,那么积木就报告一个值,就是运行该积木的结果。

    比方说,你想制作一个积木计算2个数的平均值,类似于“运算”类别的积木“+”。

    首先,当你定义积木时,应当勾选“圆形”选项:

     
    下一步,在这个新积木的“定义”堆栈,你可以用浮出控件中的积木“返回( )”来设置该积木的结果值。

     
    现在看到的这个新积木“平均数”就是圆形的。当你点击时会返回一个数:

    1 Reply Last reply
    0

    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