Negative Width for Mirrored Images

0 favourites
  • 9 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Specs:

    Construct 2 r102

    Windows 7 64-bit

    Intel Celeron

    Bug:

    When a sprite is mirrored, the width is returned as a negative value. I don't think this is expected behavior.

    Example:

    Negative Width Capx Sample

  • I think it's intended.. You mirror an object in theory by making it's width -100%.

  • This is by design. Mirroring is implemented by inverting the width.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley

    Hmmm, I'm not sure I agree with this. Width should by definition always be a positive value. Mirroring an image on a 2d plane should have no effect on the actual value. I understand that internally, mirroring may invert the width, but as a property value, width should return the measurement of an object from side to side. It's especially confusing considering that sprite rotation has no effect on the width value.

    Since I can't rely on width to return a positive value for any given sprite anymore, and most of the sprite's in my game's visual state is indeterminant, it just means I have to wrap all my Width and Height calls in Math.abs statements.

    I can't imagine a situation in a game where you would want to get a negative value for the width of a sprite. I guess you could argue that it lets you tell if a sprite has been flipped/mirrored, but there is already explicit conditional logic in place to check for that.

    I spent almost 30 minutes trying to debug a subtle issue that when I finally managed to track it down, it was because width was negative.

  • Sprite Rotation does not have an effect on the width value because it shouldn't. But open Photoshop and slowly reduce the width of an object, once you reach about 1% width, your object is a thin line and at 0% it's gone, once you reach -1% it's at the opposite/mirrored direction.

    This is the same for every software I know, even 3D Modeling software flip the scale of XYZ when you mirror them. -1 Scale in any of these axis gives you a mirrored object.

    If you want to use your width in a positive value, simply use abs() as you have stated. It's a little bit tedious, maybe, but trust me, the uses of knowing that your object is mirror through the negative value of the width is a much better and will also fundamentally help you in many ways.

  • We really can't change it, because it would break too many projects that depend on it now.

    Also, this used to not be supported, and other users told us they missed it and wished objects would flip or mirror when they go in to negative width or height! So I guess it's a matter of taste or dependent on what you're trying to achieve. Still, changing things causes big compatibility problems and I don't see why we should go through that if it already does the job.

  • Ashley

    Hmmm, I'm not sure I agree with this. Width should by definition always be a positive value. Mirroring an image on a 2d plane should have no effect on the actual value. I understand that internally, mirroring may invert the width, but as a property value, width should return the measurement of an object from side to side. It's especially confusing considering that sprite rotation has no effect on the width value.

    Since I can't rely on width to return a positive value for any given sprite anymore, and most of the sprite's in my game's visual state is indeterminant, it just means I have to wrap all my Width and Height calls in Math.abs statements.

    I can't imagine a situation in a game where you would want to get a negative value for the width of a sprite. I guess you could argue that it lets you tell if a sprite has been flipped/mirrored, but there is already explicit conditional logic in place to check for that.

    I spent almost 30 minutes trying to debug a subtle issue that when I finally managed to track it down, it was because width was negative.

    You can use the mod of the width.

  • TELLES0808: Not sure what you mean by that, modulo division isn't really suitable in this case. Taking the absolute value works fine.

    Ashley: I understand your reasoning, I'm just worried that behaviors, plugins, even collision detection that rely on Sprite.Width/Sprite.Height might suddenly exhibit erratic behavior if the Width/Height could return negative values.

    This bug that I just found concerning mirroring/scaling might be related:

    Mirroring Scaled Images fails

    Do you think I should just create separate animations for mirror/flipped images instead of using mirror/flip?

  • TELLES0808: Not sure what you mean by that, modulo division isn't really suitable in this case. Taking the absolute value works fine.

    Ashley: I understand your reasoning, I'm just worried that behaviors, plugins, even collision detection that rely on Sprite.Width/Sprite.Height might suddenly exhibit erratic behavior if the Width/Height could return negative values.

    This bug that I just found concerning mirroring/scaling might be related:

    Mirroring Scaled Images fails

    Do you think I should just create separate animations for mirror/flipped images instead of using mirror/flip?

    Absolute, that`s the word ^^ mod is how we call it in my language

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)