Placing items in a grid?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello, I have a grid of 32x32 on a 640 x 480 size frame I want to place random object on it and snap it, I have tried place X position on a random range of (0,680) and Y position on a random range of (0,480) then I get the positions and / 32 * 32 to cut remainders but can't make it work at all, it snap in the middle of grids. How can I do that better?

  • It should work, I tried myself. It works because the operation are already in integer value you dont need floor or ceiling function.
    Here the working mini code

    Please login to see this attachment.

    Or the Event List image

    Please login to see this attachment.

    Edited once, last by 1Ombra1 (March 13, 2018 at 11:27 AM).

  • That would produce a number between 0-31 for x and y.

    you could do: set xpos to Random(FrameWidth / 32) * 32 set ypos to Random(FrameHeight / 32) * 32.

    In this case you don't want the remainder so wouldn't use modular division.

  • Now that I rethink about your first post, where is setted the hot spot of your active object?
    In my little example using
    (randomX/32)*32 and (randomY/32)*32
    I setted the hot spot in the top-left corner of the 32x32 active object, if you put it in the center you need to make a little offset adjustment to the position adding ActiveWidth/2 and ActiveHeight/2.
    Sorry if in my first post I did not specify this.

    Here the example with the grid in black so you can see that it works

    Please login to see this attachment.

    Edited once, last by 1Ombra1 (March 13, 2018 at 2:41 PM).

  • I have a sneaky suspicion this is just literally down to hotspot position...

    Game Launcher Creator V3 - Please login to see this link.
    Bespoke Software Development - Please login to see this link.
    Learn Clickteam Fusion 2.5 - Please login to see this link.

    Danny // Clickteam

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!