Box2D Forums

It is currently Fri May 24, 2013 1:22 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Dec 13, 2010 4:40 am 
Offline

Joined: Sun Dec 12, 2010 9:56 am
Posts: 49
@Barliesque i agree your ScrollEase should be added. It's just what i was looking for and i've added it myself... But i've noticed a small problem. For example if you use the demo.fla with the BoxMan demo on frame 2, and have your scrollEase, then once you test/open the SWF it starts off in the center of the stage and quickly moves over to BoxMan / the focused object. It would be best if it starts off on the focused object, if thats possible.


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 4:50 pm 
Offline

Joined: Mon Apr 07, 2008 3:06 am
Posts: 99
Hi Beany,

Here's a simple resolution to the issue you mention....

Change the declaration of focus to _focus
Code:
private var _focus:DisplayObject; /// Object the viewport should center on.


...and add the following methods to the class:
Code:
public function changeFocus(newFocus:DisplayObject, ease:Boolean = true):void {
   if (ease) {
      _focus = newFocus;
   } else {
      focus = newFocus;
   }
}

public function get focus():DisplayObject { return _focus; }

public function set focus(value:DisplayObject):void {
   _focus = value;
   if (scrolling) {
      var saveEase:Number = scrollEase;
      scrollEase = 1;
      updateScroll();
      scrollEase = saveEase;
   }
}


Now, whenever the focus property is set directly, as is the case when the world is first created, there's no ease. If you want to change focus and use this ease method, then call changeFocus.


Top
 Profile  
 
PostPosted: Tue Mar 29, 2011 6:08 pm 
Offline

Joined: Tue Mar 29, 2011 5:46 pm
Posts: 9
mayobutter wrote:
Can even use tweens to animate the camera. Although in this case it would probably be simpler just to tween the whole world and use no camera...


I'm trying to do the same thing, being able to zoom (though rotate doesn't matter for me), and have tried both methods (using a camera object, and not using one). I've gotten it to work successfully in either case, but with a very bad side effect: If I try to zoom (animating the world scaleX/scaleY property) it makes the physics behave erratically. I have a projectile that I'm applying a force to, and if the world animates it's scaleX and scaleY properties while the projectile (a circle) is in the air, then the projectile wobbles in mid air and does a strange curve that defies physics. If I only animate the world.pos.x and world.pos.y then it behaves normally. But as soon as I animate the world.scaleX and world.scaleY while the projectile is in the air, then the arc of the projectile becomes very erratic.

It seems that Box2D must somehow be getting out of sync with the size changes of the world. Any ideas on how to fix this? Anyone else run into something similar? Any help would be appreciated.

Thanks!
Jacob

PS. WCK is awesome!


Top
 Profile  
 
PostPosted: Fri Apr 22, 2011 12:25 pm 
Offline

Joined: Tue Mar 29, 2011 5:46 pm
Posts: 9
For anyone else interested, I solved the problem. It turned out to be a combination of a few things, most of which were the results of my lack of experience with the engine. Zooming and panning at the same time works fine!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 2 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