Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best method in XNA to have the player paint smoothly on the screen?
    primarykey
    data
    text
    <p>I'm developing a wp7 game where the player draws lines in the program and a ball bounces off of them. I'm using XNA and farseer physics. What is the best method for a user to draw a line, and then for the program to take it and turn it in to a physics object, or at least a list of vector2s? I've tried creating a list of TouchLocations, but it ends up spotty if the user does not draw very slow, like the picture I've attached. Any suggestions? Thanks <a href="http://img829.imageshack.us/img829/3985/capturehbn.png" rel="nofollow">http://img829.imageshack.us/img829/3985/capturehbn.png</a></p> <p>Here's some code: I'm using the gamestatemanagement sample, and this is in the HandleInput method</p> <pre><code>foreach (TouchLocation t in input.TouchState) { pathManager.Update(gameTime, t.Position); } </code></pre> <p>The pathManager class manages a collection of path classes, which are drawable physics objects. Here is pathManager.Update</p> <pre><code>public void Update(GameTime gameTime, Vector2 touchPosition) { paths.Add(new Path(world,texture, new Vector2(5,5) ,0.1f)); paths[paths.Count-1].Position = touchPosition; } </code></pre> <p>This is just what I'm doing now and I'm willing to throw it out for anything. You'd think that having a 5x5 rectangle for each touch location would kill the performance, but using farseer I didn't see any drops, even with a mostly full screen. However, this system doesn't create a smooth line at all if the line is drawn fast.</p> <p>I doubt this helps any, but here is the Path constructor.</p> <pre><code>public Path(World world, Texture2D texture, Vector2 size, float mass) { this.Size = size; this.texture = texture; body = BodyFactory.CreateRectangle(world, size.X * pixelToUnit, size.Y * pixelToUnit, 1); body.BodyType = BodyType.Static; body.Restitution = 1f; body.Friction = 0; body.Friction = 10; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload