How to tile follow cursor?

For questions about using Classic.

Post » Mon Aug 01, 2011 7:16 am

I want this white isometric tile to "snap" to the the background tile that the mouse is currently overlapping.


Here is my current code:

Which is obviously incorrect, since it will avoid the "inbetween" darker tiles. I tried comparing to see if "int(mouseX/23.5)" was an odd or even number then to position it accordinly, but that didn't work.

Here is a .cap file

Anyone have any ideas?



    alspal2011-08-01 07:17:28
B
147
S
73
G
20
Posts: 1,785
Reputation: 22,420

Post » Mon Aug 01, 2011 7:29 am

Spriter Dev
B
99
S
21
G
12
Posts: 3,259
Reputation: 16,894

Post » Mon Aug 01, 2011 7:36 am

Try looking at it like this.
Your grid is basically a bunch of squares, and from your tile you can find a small square, and a larger square.


Try using the size of one of those to figure your coordinates.
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Mon Aug 01, 2011 8:39 am

Wow fantastic help, thanks a lot! :D
B
147
S
73
G
20
Posts: 1,785
Reputation: 22,420

Post » Mon Aug 01, 2011 8:50 am

no prob, btw, I think there's a slight issue with mine, if you're moving your mouse diagonally down right, it favors the higher square
slight math error somewhere
Spriter Dev
B
99
S
21
G
12
Posts: 3,259
Reputation: 16,894

Post » Tue Aug 02, 2011 1:54 am

@lucid, its probably because the hotspot was at the top left. Just had to add +23.5 to the X/Y of the first half of the compare, and remove the -23.5 from the second half of the compare.

http://dl.dropbox.com/u/1024727/caps/tilethingy2.cap

B
147
S
73
G
20
Posts: 1,785
Reputation: 22,420


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest