Negative width/height values - Flip/Mirror sprites

Get help using Construct 2

Post » Fri Oct 14, 2011 1:45 pm

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
B
107
S
40
G
10
Posts: 456
Reputation: 13,202

Post » Fri Oct 14, 2011 1:49 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Oct 14, 2011 2:08 pm

Doh! I feel like a noob for not searching it right.
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?gammabeam2011-10-14 14:14:37
B
107
S
40
G
10
Posts: 456
Reputation: 13,202

Post » Fri Oct 14, 2011 2:57 pm

[QUOTE=gammabeam] 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)[/QUOTE]

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Oct 14, 2011 3:04 pm

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?
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Oct 14, 2011 3:26 pm

Here's my .capx: http://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!
B
107
S
40
G
10
Posts: 456
Reputation: 13,202

Post » Fri Oct 14, 2011 5:31 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sat Oct 15, 2011 3:11 pm

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!

EDIT:
There's also a bug: Both Flip and Mirror do the same thing, flipping the sprite horizontally... gammabeam2011-10-15 15:29:24
B
107
S
40
G
10
Posts: 456
Reputation: 13,202


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Google [Bot], Magistross, mallorcaredes, zatyka and 23 guests