How do I use grid right [solved]

Get help using Construct 2

Post » Thu Aug 28, 2014 4:00 pm

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.

Image

"Code":
Image

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!
You do not have the required permissions to view the files attached to this post.
Last edited by McBuzzzy on Fri Aug 29, 2014 12:57 pm, edited 1 time in total.
B
7
Posts: 16
Reputation: 315

Post » Thu Aug 28, 2014 5:35 pm

Use floor instead of round, and +32 instead of -32.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Thu Aug 28, 2014 7:17 pm

Message: McBuzzzy is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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?
B
7
Posts: 16
Reputation: 315

Post » Thu Aug 28, 2014 7:19 pm

source-URL removed by system

resource was: scirra /tutorials/77/native-expressions-in-construct-2
B
7
Posts: 16
Reputation: 315

Post » Thu Aug 28, 2014 8:07 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Aug 28, 2014 8:42 pm

Thank u both
B
7
Posts: 16
Reputation: 315


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 2 guests