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. 二维项目的物理引擎

二维项目的物理引擎

Scheduled Pinned Locked Moved 二维积木
1 Posts 1 Posters 865 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.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

    介绍

    在使用创益编程平台编写二维项目时,你可以使用物理引擎来帮助你处理角色的移动和碰撞。你可以将物理引擎视为你的智能助手。你只需要描述你需要什么样的物理效果,比如“让这个球在重力作用下下落”,那么它就会负责完成具体的工作。使用物理引擎不仅能让你的程序更简洁,还能让运行结果看起来更逼真。

    许多热门的游戏都使用了物理引擎,例如“愤怒的小鸟”、“吃豆人” 或 “超级马里奥”等等。

     
     

    初始化二维物理世界

    要使用二维物理引擎,第一步是创建一个“物理世界”。与舞台或角色物体不同,物理世界是一个在幕后运作的看不见的世界。你只能通过查看它产生的结果来推断它的运行情况。

    要初始化这个物理世界,你可以使用“二维物理”类别中的这个积木:

    ea104cfb-e853-4fa8-af30-0030e39157ee-image.png

     

    这个积木有 2 个输入,分别是 X 和 Y 方向的重力加速度。

    • 对于像愤怒的小鸟这样的平台游戏,我们希望物体掉落到屏幕底部,所以应该将 X 重力值设置为 0,将 Y 重力值设置为负数,如 -100。
    • 对于像吃豆人这样的上帝视角游戏,你可以将两个重力值都设置为 0。

     
     

    物理世界的 4 个围墙

    初始化物理世界后,你还不会观察到任何差异。但是,舞台的 4 个边界上将添加 4 个隐形的围墙,这样没有物体可以移出舞台区域了:

    39e7d4a8-fd33-4970-a87e-e8004753dc40-image.png

     
    请注意,如果你在使用视窗模式,并将画布尺寸设置为大于 480 x 360,那么这些围墙也将被添加到放大的画布区域周围。

    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