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
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Mon Aug 01, 2011 7:29 am

Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

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 Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Aug 01, 2011 8:39 am

Wow fantastic help, thanks a lot! :D
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

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
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

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
134
S
65
G
16
Posts: 1,766
Reputation: 19,190


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests