Skip to content
debreuil edited this page Sep 14, 2010 · 18 revisions

How do I control the dimensions of my game window?

  • This is controlled by the size of the swf, per screen. If swfs are different sizes for each Screen, then the size will change. It is set in V2DScreen>CreateWorld if you would want to tweak how that works.

How can I change the world’s gravity?

  • Gravity (and bkg color, debugDraw) is set on the class attribute of the Screen subclass, so like:
    [V2DScreenAttribute(backgroundColor = 0x000001, gravityX = 0, gravityY = 60, debugDraw = false)]

How can I remove the default screen border collision object(s)? A couple of game ideas I’m tossing around involve the physics world being bigger than a single screen. I tried a few things but with no success yet.

  • V2DScreen has two methods for that, one is ClearBoundsBodies with takes them all out, or you can take out one by one with ClearBoundsBody(EdgeName) which you can pass TRBL.

Is there a way to make something a trigger object in Flash, so it has no physics but collision events can be subscribed to? (in Farseer it’s a Geom set to IsSensor without a Body).

  • You can make a flash object that is just a red outline, and then mark it
    [V2DSpriteAttribute(isSensor = true)]

Have you considered passing a matrix into the spritebatch draw so the screen can be panned and zoomed?

  • The Camera class in the Sleepwalker source is doing this. It sets the Stage.SpriteBatchMatrix. (That code is here if you don’t have it yet). Camera will at one point be integrated into the main source.

Does Swf2XNA convert to Xna 4 and build for WP7?

  • It has been tried it on the ZuneHD (a while back), and it worked. I haven’t tried on WP7 (running XP on all machines here). It ‘should’ work though, if not it would be minor tweaks (it basically only uses SpriteBatch).

Would you be open to patch submissions if I make a change I consider useful for others? If so, how would you like it formatted, or does Git have a patch submission feature built in?

  • Certainly! Not sure about formatting, there must be some kind of patch thing in git. I’m sure I could find a way to work with whatever you send, and then develop stronger opinions pretty quickly : ).

I see you have plans to support other physics engines. I’m personally fond of Farseer.

  • It was written for that to be possible, there may be box2d api leakage, but should be very doable.

One feature Farseer has is the ability to split concav polys into multiple convex ones (ear clipping algo). I guess you (or I) could borrow their code as the 8-vert-concave-poly limit in Box2D is a little annoying. Would this be a useful addition?

  • Planning on adding code that busts up the red outlines, at the point it is reading in from the swf. Code that did that would certainly be useful : ). Btw the 8 poly limit in Box2D can be set — probably that should be settable via a V2DScreenAttribute, noted.

How difficult do you think it would be to make a Swf2Xna component work in a different framework (ie without a Screen, eg hosted in a custom component from a different framework)?

  • I think it would be hard to run it without the framework, and without screen, but I believe that whole layer can run independently of a game. So if you wanted to make a hud, I’m pretty sure you could have a hud screen, and just call update on that. Otherwise you could also just have screen call into your game’s update (like in the demos with the 3D ships), but that would be clunkier. It would allow potential layering though of swf|3D|swf, where the other way wouldn’t.

Can you replace the 2D swf objects with 3D

  • Yes, basically use a body only (red outline only) swf object. Then just move the 3D object in update. That could probably be integrated, currently it would be manual or in a subclass of sprite.

(thanks to Aranda Morrison for these)
((if you have questions, please feel free to send them along))

Clone this wiki locally