Picking Tiles between two points (t2dTileLayer)
by Richard Skala · in iTorque 2D · 04/22/2010 (10:41 pm) · 1 replies
Is there a way to select any tiles between two t2dVector positions? I need to get all the tiles the user has touched when sliding his finger across a t2dTileLayer.
When the user swipes his finger across the t2dTileLayer object, the 'onMouseDragged' event is called. You can get the "mouse (finger) position" in this callback, and then can successfully pick the appropriate tile from it. However, this only works if the user drags his finger SLOWLY. If the user swipes really fast, then the distance between subsequent t2dVector positions sent to 'onMouseDragged' will be very large. That is, when using "PickTile" on those positions, you will not get all the tiles between those points.
So, is there a way to specify two positions and get all the tiles that lie between those two positions?
Thanks for any input.
When the user swipes his finger across the t2dTileLayer object, the 'onMouseDragged' event is called. You can get the "mouse (finger) position" in this callback, and then can successfully pick the appropriate tile from it. However, this only works if the user drags his finger SLOWLY. If the user swipes really fast, then the distance between subsequent t2dVector positions sent to 'onMouseDragged' will be very large. That is, when using "PickTile" on those positions, you will not get all the tiles between those points.
So, is there a way to specify two positions and get all the tiles that lie between those two positions?
Thanks for any input.
About the author
Founded in 2009, Pixel Vandals Inc. is focused on bringing fun, fresh, and new ideas to the iPhone. www.pixelvandals.com www.pixelvandals.com/vineking
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
as you know the tilesize you can calculate the distance between checks easily
Alternatively due it pure logically:
you have a start tile and an end tile and their tile coords. So with some simple line algorithm like bresenham you can calculate all the other tiles on the line