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
141
S
68
G
17
Posts: 1,769
Reputation: 20,224

Post » Mon Aug 01, 2011 7:29 am

Spriter Dev
B
96
S
21
G
12
Posts: 3,256
Reputation: 16,813

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
164
S
49
G
139
Posts: 7,967
Reputation: 92,400

Post » Mon Aug 01, 2011 8:39 am

Wow fantastic help, thanks a lot! :D
B
141
S
68
G
17
Posts: 1,769
Reputation: 20,224

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
96
S
21
G
12
Posts: 3,256
Reputation: 16,813

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
141
S
68
G
17
Posts: 1,769
Reputation: 20,224


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests