Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

phoenix.Camera.center confusion #251

Open
ghost opened this issue Mar 15, 2015 · 3 comments
Open

phoenix.Camera.center confusion #251

ghost opened this issue Mar 15, 2015 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Mar 15, 2015

Setting phoenix.Camera.center does not effect the camera immediately.
These features are also broken as a result: luxe.Camera.center, luxe.Camera.focus.

@ruby0x1
Copy link
Member

ruby0x1 commented Mar 15, 2015

There are definitely some things going on that are being resolved in the new vectors (mentioned in the dev log briefly) and there are a few issues already listed for this like #110 #106

I noticed you mentioned focus as a way to follow during a movement - that's a tween and will create a new tween every time you call it, which is not ideal of course.

If you want to follow with some form of smoothing you should look at Vector weighted average or the maths counterpart it's using. Then every frame you do camera pos = weighted average( dest pos , slowness ) instead of using focus.

With regards to the center: can you run tests/features/camera_views as that uses the center and seems to still be working (press arrow keys), I'm just curious.

@ghost
Copy link
Author

ghost commented Mar 15, 2015

OK, I see now. Then I won't submit a pull request, since its probably not going to be valid once those systems are rewritten. Got it.
I'll take a look at alpha-2.0 and see if there is anything I can do to help progress towards 1.0.0 beta.

@ghost
Copy link
Author

ghost commented Apr 2, 2015

While I was looking at the internals of luxe.Camera and phoenix.Camera for another reason, I came across the problem I was experiencing.
In phoenix/Camera.hx, line 491 in set_center:

                    pos.ignore_listeners = true;
                        pos.x = _p.x - (viewport.w/2);
                        pos.y = _p.y - (viewport.h/2);
                    pos.ignore_listeners = false;

The position vector is updated, but ignore_listeners is set to false, so the change doesn't propagate properly. A solution would be to swap the last two lines.
Another issue related to this is what appears to be an attempted work around, in luxe/Camera.hx, line 115 in set_center,

        pos = new Vector(_c.x - (viewport.w/2), _c.y - (viewport.h/2));
        return view.center = _c;

By setting luxe.Camera.pos, this partially "fixes" the above bug, but it doesn't change luxe.Camera.view.pos until the next update(), which can cause the camera to jitter. So the assignment to pos in luxe.Camera.set_center should be removed.

Until this is fixed, you can force view.pos to be updated by doing camera.view.pos = camera.view.pos

@ruby0x1 ruby0x1 added the camera label Apr 24, 2015
@ruby0x1 ruby0x1 changed the title phoenix.Camera.center is broken phoenix.Camera.center confusion May 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant