FlxCamera.shake() problem with black edges

344 views
Skip to first unread message

solewalker

unread,
Aug 29, 2014, 3:05:28 AM8/29/14
to haxef...@googlegroups.com
I am having the same problem as the OP in this post http://forums.flixel.org/index.php?topic=4977.0

Problem is that when camera shakes, it's not really view that's shaking, but screen shakes instead. So because of that stronger the shaking is, more of the black edges can be seen...

Why is this done this way anyway ?   I guess if I change that scroll is changed by small random amount, I will get the effect I want ?

If someone already done it, please paste it here. :)  Thx.

EDIT : done..  Change scroll to private, and change its name to _scroll. Then make new public get function with name scroll, and make that it returns  FlxPoint _scroll.x + shake.x, _scroll.y + shake.y ..  And then just throw out the part that changes x and y of the screen...

Even if I center my camera into the map, shaking the screen shows black edges, not more part of the map. I have found this thread, but as I am new to flixel, I don't understand how he fixed it? Is there any other way around this issue, without hacking into source? Or, what exactly he was talking about? I need this workaround, as my map size is bigger than the camera. Another solution could be I implement my own shake method. But if it's provided in the framework, no need to reinvent the wheel. Thanks upfront.

solewalker

unread,
Aug 30, 2014, 12:32:19 AM8/30/14
to haxef...@googlegroups.com
Bump :)

MegaLeon

unread,
Aug 30, 2014, 9:02:23 AM8/30/14
to
Yeah, I find this strangely annoyning too. 
You can see from the FlxCamera demo that we see the black borders even if we zoom out from the camera: it would be great to have the chance to select whether adopting this behaviour OR displaying the rest of the game area (something like a FlxCamera.BorderMode?) - or at least using the FlxCamera.bgColor instead of black!

Gama11

unread,
Aug 30, 2014, 9:43:32 AM8/30/14
to
shake() simply modifies the x / y position of the camera viewport, which is why you're seeing this. It might be possible to modify scroll.x / y instead, or increase the camera dimensions sufficiently.

It doesn't "use" FlxCamera.bgColor because the camera ends there / the black borders are not part of the camera. That color is determined by the color attribute of the <window> tag in your Project.xml:

<window background="#000000" />

Ohmnivore

unread,
Aug 30, 2014, 10:39:45 AM8/30/14
to haxef...@googlegroups.com
Although I almost never use shake I'm still surprised why there's no option to shake the scroll values rather than the viewport. I think it's a pretty easy fix but I haven't attempted it yet.

solewalker

unread,
Aug 30, 2014, 11:22:08 AM8/30/14
to haxef...@googlegroups.com
I guess implementing my own camera shake is the way to go for now, but current shake behavior is not suitable in many cases, don't know why it's this way.

On Friday, August 29, 2014 1:05:28 PM UTC+6, solewalker wrote:

Ohmnivore

unread,
Sep 6, 2014, 2:47:15 PM9/6/14
to haxef...@googlegroups.com
Uhm guys, replace on line 992 (FlxCamera.hx)

flashSprite.x += _fxShakeOffset.x;
flashSprite.y += _fxShakeOffset.y;

by

scroll.x += _fxShakeOffset.x;
scroll.y += _fxShakeOffset.y;

with the black edges gone I find that the shake is a lot less nauseating then it used to be.

solewalker

unread,
Sep 7, 2014, 2:35:24 AM9/7/14
to haxef...@googlegroups.com
This solution does not work well, as scroll can't get negative or go outside camera bound, also when camera starts following the player it gets weird. I have to stick with the default one for now, when I get time I have to implement my own.
Reply all
Reply to author
Forward
0 new messages