Hey everyone
In my current game, I've been scrolling the physics world.
The problem is that this produces some odd visual effects and after researching it, I've read you should not scroll the box2D world but instead adjust the camera view.
I'm trying to get my head around scrolling without scrolling the box2D world... if that makes sense
Thanks
Tom
Comments
http://www.giderosmobile.com/forum/discussion/729/moving-screen-in-box2d-world#Item_21
So this might help
http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-Move
Basically you need to move the scene (by changing it's positions) because all objects inside scene are relative to scene's anchor point and not scene position, thus they will equal box2d coordinates. If that makes any sense
Likes: Tom2012
I'll research into those links now
self:setX(offsetX)
self would be the sprite that is the scene? So everything is added as a child of the scene, and then the entire scene is scrolled?
Thanks
If you're scrolling the entire scene, how do you not scroll certain elements - such as the HUD?
My logic was to create a 'physics layer' as a child of the scene, and scroll that. But that's different to your idea - and your's works!
I suppose you would add all scrolling elements to a sprite (scroller) and all static elements to a sprite (hud) then add these to the stage and only do self:setX(offsetX) on the scroller
cheers
evs
If I change the mouseDown part to:
I think this is because the ball is moving and then the world is being scrolled on that frame too. Can you reproduce this problem?
Thanks!
Example attached.
Likes: Yan
Here's the Camera class I'm using for my box2D world.
==============
- physicsLayer contains my physics world
- I manually set self.worldWidth and height at the start of each Level scene
- I run the update part from the enterFrame loop that updates the physics world
- AFTER the for loop...
Likes: ar2rsawseen
This code is great, but I was wondering if someone could help me. I am trying to setup a mousejoint on the ball so I can drag it around the screen instead.
This works ok until the scroll the screen and it goes horribly wrong.
any ideas?
http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-Move
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975