06-16-2011, 07:21 AM
In the UMS, windows positions are given by the methods screen_x and screen_y of the class Game_Character (and thus Game_Player and Game_Event).
You need to use the positions of the graphics elements instead of these ones.
In HM7, sprites are not used to display character but surfaces (HM7::Surface). That means that you have to get the surface linked to a character. The easiest way to do this is to add an attribute to the Game_Character class (attr_accessor :surface) and initialize it when a new surface is created (in the method initialize of the class HM7::Surface, add : character.surface = self).
Then if you are in HM7 mode and you have a character with character.surface != nil, it is possible to get the coordinates.
The methods screen_x and screen_y of the class HM7::Surface return the x and y coordinates in the screen, as if the map was flat (so without the y-offset due to the altitude).
The method get_zoom returns the zoom value.
If the camera is set in the default [C0] mode, the corrected y value is given by :
surface.screen_y - (surface.altitude * $game_temp.sin_alpha >> 14) * surface.get_zoom
If you're in [C1] or [C2] camera mode, it is a little more complex since you have to add to the obtained y value the y-offset of the tilemap : it is the variable @vars[4] that can be found in the class HM7::Tilemap.
You need to use the positions of the graphics elements instead of these ones.
In HM7, sprites are not used to display character but surfaces (HM7::Surface). That means that you have to get the surface linked to a character. The easiest way to do this is to add an attribute to the Game_Character class (attr_accessor :surface) and initialize it when a new surface is created (in the method initialize of the class HM7::Surface, add : character.surface = self).
Then if you are in HM7 mode and you have a character with character.surface != nil, it is possible to get the coordinates.
The methods screen_x and screen_y of the class HM7::Surface return the x and y coordinates in the screen, as if the map was flat (so without the y-offset due to the altitude).
The method get_zoom returns the zoom value.
If the camera is set in the default [C0] mode, the corrected y value is given by :
surface.screen_y - (surface.altitude * $game_temp.sin_alpha >> 14) * surface.get_zoom
If you're in [C1] or [C2] camera mode, it is a little more complex since you have to add to the obtained y value the y-offset of the tilemap : it is the variable @vars[4] that can be found in the class HM7::Tilemap.
Some scripts :
Working on :