How do I use grid right [solved]

0 favourites
  • 6 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hi,

    First: Sry for my bad english

    Problem: I try to make a turredbased game with pathwalking monsters and player-builded turrets. I want the turrets to snap to a grid while "inHand". My grid is 64,64 and i have a tiledBackground with 64,64 squares. I want the turrets to snap to a 64,64 grid but offset 32,32 so they snap in the middel of my backgroundsquares. I have a solution that works but "feels" bad by moving the tower "inHand" arround, u will understand while runing the app.

    "Code":

    Solution: Is there a way u set a second grid with a offset 32,32 or a way to do it like i did without that feeling by moving the mouse arround when turret "inHand"?

    Thanks for help!

  • Use floor instead of round, and +32 instead of -32.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • U did it! Thank you.

    It works good. But i dont understand why. U (or someone else) can help me further to understand IF u want to. If not, it's ok.

    Example:

    Grid is 64,64

    mouse.X = 150

    mouse.Y = 150

    Round: 150 / 64 = 2.34; rounded = 2 * 64 = 128

    Floor: 150/ 64 = 2.34; florr = 2 *64 = 128

    resource: Where is my mistake?

  • source-URL removed by system

    resource was: scirra /tutorials/77/native-expressions-in-construct-2

  • Round: 150 / 64 = 2.34; rounded = 2 * 64 = 128

    Floor: 150/ 64 = 2.34; floor = 2 *64 = 128

    but:

    Round: 175 / 64 = 2.73; rounded = 3 * 64 = 192

    Floor: 175/ 64 = 2.73; floor = 2 *64 = 128

    by using floor it rounds down, and using +32 makes it so it falls on the 32 grid..

  • Thank u both

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)