advance wars style grid

Get help using Construct 2

Post » Sun Feb 23, 2014 8:23 am

Is this the kind of thing your looking for?
https://www.dropbox.com/s/r93yk7anwcwi3g3/tileinfo.capx
B
9
S
2
Posts: 68
Reputation: 768

Post » Sun Feb 23, 2014 12:37 pm

w4rr3np34c3 wrote:So I'm starting to understand arrays a bit more but still feel like a complete noob, I tried setting some text every tick to "TileProperties.At(Mouse.X,Mouse.Y)" but I am assuming that it's the wrong way as it stays at a constant "0" I'm pretty much just going by trial and error at this point xD


Yeah that will most likely give you a 0 :)

The reason for this is probably because there are no data stored at the given position.

As you move the mouse around, you constantly update where in the array you are reading data from. So if your layout is 1000x1000 pixels. And you move the mouse around you will look up data in the array based on pixels rather than tiles. This is because each tile in the tilemap is not 1x1 pixel big, but might be 32x32 or whatever you have chosen.

If we assume that each tile is 32x32, then the array at position (0,0) would actually be all pixels from 0-31, 0-31.

So what you have to do in order to get "TileProperties.At(Mouse.X,Mouse.Y)" to work, is to convert the mouse-position into a tile position. which is fairly easy, using the tilemap function PositionToTile(X,Y).

So your function should look like this:

TileProperties.At(Tilemap.PositionToTile(Mouse.X), Tilemap.PositionToTile(Mouse.Y))
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Tue Feb 25, 2014 2:22 pm

Thanks again guys :D lifesavers you are.
B
7
S
3
G
1
Posts: 18
Reputation: 1,111

Post » Sun Jul 12, 2015 7:01 am

MiniHulk wrote:Is this the kind of thing your looking for?
https://www.dropbox.com/s/r93yk7anwcwi3g3/tileinfo.capx


Reviving the thread, does anyone have this downloaded? The link is dead :(
B
71
S
24
G
11
Posts: 452
Reputation: 12,343

Post » Sun Jul 12, 2015 4:02 pm

If you want the grid always there, you could add the grid outline to the tiles in the tilemap.

EDIT: Oops, didn't see how old the comment was that I was responding to...Sorry!
B
11
S
2
G
1
Posts: 79
Reputation: 842

Previous

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 14 guests