Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Rendering Layers

    3D Blocks
    1
    1
    224
    Loading More Posts
    • 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.
    • info-creaticode
      CreatiCode last edited by admin

      Introduction

      In CreatiCode, you can place objects in different “rendering layers”. There are 4 rendering layers in total. All objects in layer 0 will be drawn on the stage first, followed by all objects in layer 1, etc. By default, all objects are in layer 0.

      Rendering layers can help you achieve very interesting visual effects, such as making one object always show on top of another object.

      The block to set the rendering layer for the current sprite object is:

      aa3ad68c-e23b-41f7-9f64-d8ec08c975d6-image.png

       
       

      Example 1 - Unblocking An Object

      In this example, we have placed a red sphere behind a green box:

      4900c394-08f1-4166-a857-53eaed91d772-image.png

       
      As a result, the sphere is blocked by the box:

       
      However, if we set the rendering layer of the sphere to 1, then it will be drawn after the box is drawn, so we can always see it completely. This is as if the box is allowing us to see the sphere through it.

      b2.gif

       
       

      Example 2 - Highlighting An Object

      The rendering layer is especially useful when we are highlighting an object. In this program, we are trying to highlight the sphere in yellow. The green box is semi-transparent, so we can see the sphere through it.

      cc1aa65b-59f0-4d66-94f0-9b09854e2d40-image.png

       
      However, the highlighting is not working for the sphere. The portion of the sphere that’s behind the box will all be covered in yellow, though we only want to show a yellow contour around it.

      b3.gif

       
      To solve this problem, we can move the red sphere to rendering layer 1. This way, we draw the sphere and its highlighting colors after the box is already drawn, so we get the correct result:

      b4.gif

       
      Whenever you need to highlight an object that’s blocked by another transparent object, you can use this technique.

       
      You can play with this example here:

      https://play.creaticode.com/projects/6eb3f6954926ab8db962ae20

      1 Reply Last reply Reply Quote 0
      • First post
        Last post