YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

In-Game: draw_surface() draw position and contents are affected by image_scale of the object drawing itself to the surface #7747

Closed batblaster closed 3 weeks ago

batblaster commented 4 weeks ago

Description

Hi, if you draw a surface from the draw even't of an object that has a sprite assigned to it the surface draw seems to be affected from the image_xscale of the original sprite in the moment it is drawn. Considered the surface has always his origin at 0,0 you should not be affected by the scale of the object.

If i have an object 64x80 with his orign on bottom center and i draw a sprite with xscale 1 or -1 it flip normally but if i draw the same sprite into a surface and after i draw the surface the xscale affect the position of where the object will be drawn because it consider the origin the surface origin at 0,0 and not the sprite origin. A surface should be not affected by the scale of the sprite.

image_index is positive: image

image_index is negative: image

Steps To Reproduce

  1. Start GameMaker and import test_scale-Dan.zip
  2. Run it (e.g., Windows VM)
  3. Observe the images are drawing okay
  4. Press-and-release spacebar to toggle the image_scale *= -1
  5. Observe the blue surface is now lacking its proper contents

Which version of GameMaker are you reporting this issue for?

IDE v2024.8.1.171 Runtime v2024.8.1.218

Which operating system(s) are you seeing the problem on?

Windows 10.0.22631.0

Which platform(s) are you seeing the problem on?

PlayStation 4, PlayStation 5, Switch, Windows, Xbox One & Series X/S

497dba82-0a6d-4073-a654-4ebc041b7f31

batblaster commented 3 weeks ago

It seems that using image_xscale = -1 the sprite_width instead of return 64 it return -64

jackerley commented 3 weeks ago

You're using sprite_width/2 to set the x position of where the sprite is drawn, this factors in image_xscale, so when you set image_xscale sprite_width/2 is -32 and so the sprite is rendered off the surface.

batblaster commented 3 weeks ago

Sorry something is weird. After so many release now i see that the image_xscale affect the sprite_width of a sprite_index that is crazy from my point of view because a size should be always a positive number, a wall is of 1 meter not -1 meter if you look at it from the other side. Anyway the problem is simple, if i write into a surface normally using 0,0 how the image_xscale applied to the object will affect the render of the surface ?

jackerley commented 3 weeks ago

Sorry, I would tend to agree with you that sprite_width should be positive, but it's not something we can change now without potentially breaking projects. I'm not entirely sure what you are asking with your final question?