Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Tile Editor tile selection (https://forums.graalonline.com/forums/showthread.php?t=134264874)

iBeatz 10-26-2011 04:26 AM

Tile Editor tile selection
 
Can anyone explain to me clearly as to exactly how you would go about selecting a group of tiles in a GuiDrawingPanel using the onMouseDragged event.
I just want the maths and code aspect of this, nothing fancy. Also, before you direct me to an example of a tile editor doing this, I've already searched the forums and can't make sense out of any of them.

fowlplay4 10-26-2011 06:20 AM

1. onMouseDown: Determine the tile the mouse is currently over and use it as your top-left reference point.
2. onMouseDragged: Determine the tile the mouse is currently over and use it as your bottom-right reference point.
3. onMouseUp: Do whatever with your selection.

I believe:

tile_x = mouse_x - (mouse_x % tile_width);
tile_y = mouse_y - (mouse_y % tile_height);

Will get you the top-left x and y of the tile your mouse is currently over.

% is for modulus which basically gives you the remainder from dividing a number. I.e: 20 % 16 equals 4.

iBeatz 10-26-2011 02:15 PM

Thanks!
One thing that I can't seem to do is get the mouse position on the tileset image according to the positioning of the screen the GuiDrawingPanel is at.
Any idea?

fowlplay4 10-26-2011 03:30 PM

You should be able to get the mouse x and y from params[1] and params[2].

onMouseDown(keymodifier,mousescreenx,mousescreeny, clickcount)
onMouseDragged(keymodifier,mousescreenx,mousescree ny)
onMouseUp(keymodifier,mousescreenx,mousescreeny)


All times are GMT +2. The time now is 10:56 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.