FlixelCommunity / flixel

Community fork of Adam “Atomic” Saltsman's popular game engine Flixel. Distilled from a variety of Flash games he worked on over the last couple years, including Gravity Hook, Fathom and Canabalt, its primary function is to provide some useful base classes that you can extend to make your own game objects.
http://flixelcommunity.org/
Other
84 stars 17 forks source link

FlxG.camera.setBounds no longer works? #165

Closed SeiferTim closed 11 years ago

SeiferTim commented 11 years ago

Trying to check out the lastest version of the Community code, and most everything seems to be working fine, except that the bounds I'm setting on my camera no longer seem to work...?

Previously, if I said FlxG.camera.setBounds(0,0,1000,800); then I have a FlxSprite that is set to be followed, when it gets to the far left, the camera will stop without showing anything with x < 0... that is no longer true...

SeiferTim commented 11 years ago

Hm, it does stop, but it's like.... if my left bound = 0 then it treats it as -160...

SeiferTim commented 11 years ago

I 'fixed' it by changing:

if (zoom > 1)

to

if (zoom > 1 && zoom != defaultZoom)

in FlxCamera.as on line 327... This might only work for me since my camera's zoom is the same as my defaultZoom...

Dovyski commented 11 years ago

That if (zoom > 1) you changed was added with this pull request. Do you have any code I can use to test your fix and investigate the problem even further, @SeiferTim ?

SeiferTim commented 11 years ago

Um, I don't really have any simple code to share - I stuck this new version into an already coded project and that's when I noticed the problem.

xyroclast commented 11 years ago

I, too switched to Flixel Community on an existing large project, and the camera began behaving like this for me as well. I'll see if I can dig some relevant bounds/camera code out of it that might help

xyroclast commented 11 years ago

Here are my dimensions/pixel resolution/etc. from my main main FlxGame-extending class:

super(320, 240, MenuState, 2); FlxG.worldBounds = new FlxRect(0, 0, 3000, 480);

Here's my camera setup code from my FlxState-extending game state:

private function setupCamera():void { FlxG.camera.follow(Game.player,2.5); FlxG.camera.setBounds(0,0,3000,480); }

That's all I can think of offhand that might be relevant. Hope it helps!

Dovyski commented 11 years ago

Thanks for the hints, guys! I will investigate the problem.

xyroclast commented 11 years ago

Added note: SeiferTim's fix didn't have any effect in my case

xyroclast commented 11 years ago

I'll see about trying older versions til the problem goes away, and see if I can pinpoint any more insight for you

xyroclast commented 11 years ago

Update: I've determined which commit introduces the bug: https://github.com/FlixelCommunity/flixel/commit/6f3ca287f01f82167eebb9c7cbf8e3df3738a085#org/flixel/FlxCamera.as

xyroclast commented 11 years ago

It's been in place for 7 months, so it must be fairly obscure

Dovyski commented 11 years ago

I will revert the commit that introduced the bug. The camera should behave properly again.

Dovyski commented 11 years ago

I've just merged the fix https://github.com/FlixelCommunity/flixel/commit/3c49912072abdbd66f01c3cc361f5fa671303e87 . The camera should work properly again.