Negative width/height values - Flip/Mirror sprites

0 favourites
  • 8 posts
From the Asset Store
Sync animations, animation frames, mirror state, sounds and anything else using these methods.
  • I'm trying to make a sprite flip, but I noticed I can't input negative values to the width or height, as I previously could in CClassic.

    Should we have this implemented as well? If not, what's the best/correct way for achieving a flip/mirror effect without using the automatic version?

    PS: I also had a tough time trying to figure out what was going on with my sprite collision, until I noticed the "auto-guess" was on by default <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Flip/mirroring is done by changing the angle of the sprite.

    Negative values for height and width are to "ban" from use.

    There are a few samples through this "how do I section", scattered around.

    Search for "negative width" you should find the topics back with a more complete answer by Ashley.

  • Doh! I feel like a noob for not searching it right. <img src="smileys/smiley9.gif" border="0" align="middle" />

    Thanks Kyatric!

    I read the auto mirror explanation, and I tried it but I had a bug: When rotating 180 degrees with the auto mirror (or flip) on, the sprite disappeared.

    (EDIT: Just checked it and the sprite is there, hasn't been destroyed or anything... It simply disappeared)

    Anyway, I'm afraid the auto feature won't work for me...

    May I suggest a "flip horizontal" and "flip vertical" to be added to the list of actions? I believe it may be easier to use and understand it that way. What do you think?

  • I read the auto mirror explanation, and I tried it but I had a bug: When rotating 180 degrees with the auto mirror (or flip) on, the sprite disappeared.

    (EDIT: Just checked it and the sprite is there, hasn't been destroyed or anything... It simply disappeared)

    It happens when the "Preview mode" is set to "File" in the project properties.

    Turn it to "HTTP" and the auto-mirror/flip will work as intended.

  • HTML5 canvas doesn't support negative widths or heights so I had to change how it works - now it uses the angle. As Kyatric says it only works in HTTP preview mode - if you are still having issues maybe post your .capx?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's my .capx: dl.dropbox.com/u/7324985/smellyFlip.capx

    (press Z to rotate 180 degrees, or hold X to rotate it slowly 1 degree per tick)

    I am using "HTTP" as the option (it's the default right?), but the problem was still happening.

    So I made another test, this time slowly rotating the sprite by 1 degree... And it flipped! After that, changing the angle in 180 degrees increments did the trick.

    I am using Firefox, running C2 in a XP windows through Parallels on a Mac (phew!)

    As I said on my previous post, I'm not sure I'll be able to use the angle system for flipping the sprite: I'll be using a "look at" mechanics, and they will surely conflict with the flipping... Is there any other way for doing it apart from rotating the sprite?

    Thanks in advance! <img src="smileys/smiley2.gif" border="0" align="middle" />

  • The disappearing thing is a little bug, it's fixed in the next build. It actually disappears for one tick only, but if nothing else is going on then the screen is not redrawn.

    If you need mirroring not based on changing the angle, I think the easiest thing to do is actually just to mirror it in the animation editor and set the animation.

  • Hi Ash

    I've been experimenting with the flip stuff and I'll have to follow your advice and double the animations for each sprite that needs both rotating AND flipping.

    I hope we can have flip and mirror (or rather flip vertical and horizontal) actions for sprites soon! <img src="smileys/smiley4.gif" border="0" align="middle" />

    EDIT:

    There's also a bug: Both Flip and Mirror do the same thing, flipping the sprite horizontally... <img src="smileys/smiley19.gif" border="0" align="middle" />

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