Box2D Forums

It is currently Sun May 19, 2013 8:47 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Wed Apr 04, 2012 11:18 pm 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
Hi,

I am making a bow and arrow game using WCK engine. And i have made a camera using the technique where you scale the world by scaling the camera object for zooming in the Physics world. Everything works fine when the camera is not scaled. But as soon as i scale the camera for scaling the Physics world. The world scales but the physics goes awry. The physics doesn't behave as i want.

Any kind of help would be appreciated. Thanks.


Top
 Profile  
 
PostPosted: Thu Apr 05, 2012 9:22 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
Assuming, by Physics world you are referring to the box2d world, do you really need to scale the physics world? I haven't tried it yet, but why don't you just scale the Flash/display world?


Top
 Profile  
 
PostPosted: Thu Apr 05, 2012 11:11 pm 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
I just did a quick test and it seem to work fine with object collisions.

Is your code something along the lines of:
Code:
world = new wck.World;
...
world.scaleX = world.scaleY = newScale;


Top
 Profile  
 
PostPosted: Fri Apr 06, 2012 1:57 am 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
Yeah. I overrided scrollRotation as suggested in this topic viewtopic.php?f=19&t=5994


Code:
public override function scrollRotation():Number
      {
         
         //if orient to gravity set, do rotations of the world based on gravity
         if (orientToGravity)
         {
            var b:BodyShape = focus as BodyShape;
            var g:V2 = getGravityFor(V2.fromP(pos).divideN(scale), b ? b.b2body : null, b);
            return (Math.atan2(g.y, -g.x) * Util.R2D) - 90;
         }
         
         //if orient to focus set, manipulate the world based on the properties of the focus object (ie. the camera)
         if (orientToFocus)
         {
            scaleX = focus.scaleX;
            scaleY = focus.scaleY;
            return focus.rotation;
            trace(this.x);
         }
         
         //else just return standard rotation
         return rot;
      
      }


Top
 Profile  
 
PostPosted: Fri Apr 06, 2012 2:51 am 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
Collisions are working fine But in my game i have applied impulse to my arrow which is made up of three parts. But the parts are breaking off if i scale down the world.


Top
 Profile  
 
PostPosted: Fri Apr 06, 2012 3:38 am 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
It's acting weird even when i scale the movieclip on which i have added the box2d world. Any suggestions for building a camera for zooming and panning?


Top
 Profile  
 
PostPosted: Sat Apr 07, 2012 10:44 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
I just skimmed through the link you posted and it seems like that others were able to make it work. Perhaps, you may need to look at your engine.

Instead of adding the world to your movieclip, create the world first, and then add your movieclips. Then scale the world, as I referred to in my earlier post.

Perhaps my variable naming wasn't be best, so:
Code:
myWorld = new wck.World;
myWorld.scaleX = myWorld.scaleY = newScale;


Top
 Profile  
 
PostPosted: Sun Apr 08, 2012 10:46 am 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
I can't do that as i am working on a template and therefore i have to create a movieclip and add my world there.


Top
 Profile  
 
PostPosted: Mon Apr 16, 2012 11:18 pm 
Offline

Joined: Sun Mar 13, 2011 12:35 pm
Posts: 19
Any Help? The Physics works properly till 0.6 scale, after that it breaks down.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group