GMS 2 [SOLVED] Keep Sprite in Same Position Relative to Obj Scale?

Divinik

Member
So I have a simple scale calculator used for scaling active actors relative to their horizontal position on the screen during the battle sequences of the game.

The code for that is:
Code:
battleScale = (distance_to_point(x, camera_get_view_y(camera)))*0.0025;

image_xscale = battleScale*direction_scale;
image_yscale = battleScale;
There is another object for the active actor's weapon, and it's position is linked to the frame that the actor's object is currently on:
Code:
if sprite_index = spr_katana or sprite_index = spr_rapier
  {
   if cur_seq = 2
     {
      if parent.image_index = 7
        {
        wep_scale = 1.3;
        wep_inversion = -1;
        visible = true;
        image_angle = -180;
        y = parent.y+32);
        x = parent.x+15;
        }
       
      if parent.image_index = 8
        {
        image_angle = -100;
        y = parent.y-10;
        x = parent.x+72;
        }

and so on...
Is their a mathematical way to ensure that no matter the scale of the actor the weapon sprite will be drawn at the same relative position of the actor's sprite according to it's scale?
 

Divinik

Member
Just figured it out:

Code:
x = parent.bbox_left+((parent.bbox_right-parent.bbox_left))*0.70;
y = parent.bbox_top+((parent.bbox_bottom-parent.bbox_top))*0.60;
 
Top