Navigation

    CreatiCode Scratch Forum

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

    The "Distance to (object)" Block

    2D Blocks
    1
    1
    1012
    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

       

      Prerequisite

      • Working with Blocks

       

      Description

      The “Distance to (object)” block is a reporter block in the sensing category.


       

      How does this block work?

      This block tells the distance of the current sprite from the selected object. You can click on the drop-down menu to choose the “mouse-pointer” or another “sprite” as the target object.


       
       

      Distance to (mouse-pointer)

      When you select “mouse-pointer” as the target object, the block tells the distance from the current sprite to the mouse-pointer.

      As shown in the example below, whenever the "distance to (mouse-pointer) block is clicked, it tells the distance from the player (current sprite) to the mouse-pointer. This block works no matter if the mouse pointer is inside the stage window or outside of it.


       

      Distance to (sprite)

      When you select a “sprite” as the target object, the block tells the distance from the current sprite to the selected sprite.

      As shown in the example below, whenever the "distance to (Basket ball) block is clicked, it tells the distance from the player (current sprite) to the basket ball (selected sprite).

      Note: You need to have at least two sprites in the project before you can select another sprite from the drop-down list.


       
       

      Animation

      Here is a basketball game animation that you can create with the “distance to (object)” block.
      Whenever the distance of the basketball to the basket is less than or equal to 70, the backdrop shows “GOAL”.


       

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