I'm a monogam developer, and I'm working on a project that users can use with their finger
The phone screen, I do this with the duplication of a picture on the path of a finger:
I used some code like this:
Loadconent method
Texture = Content.Load & LT; Texture2D> ("B3");
renderTarget = new RenderTarget2D (this.GraphicsDevice, this.GraphicsDevice.PresentationParameters. BackBufferWidth, this.GraphicsDevice.PresentationParameters.BackBufferHeight, False, this.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat .None, 0, RenderTargetUsage.PreserveContents);
update method
safe override zero updates (gametime gametime) {touch pen touch = touchpanel. Gatestate (); Foreign (Touch touch in touch) {if (touch.State == TouchLocationState.Moved) {GraphicsDevice.SetRenderTarget (renderTarget); SpriteBatch.Begin (); Spritebatch.Draw (texture, touch composition, color white); SpriteBatch.End (); GraphicsDevice.SetRenderTarget (zero); }} Base.Update (gameTime); }
Draw method
Protected override zero draw (gametime game time) {Graphics Device. Clear (color white); // TODO: add your drawing code here (spritebatch.begin); Spritebatch.Draw (Render Trayjet, Vector 2. Zero, Color White); SpriteBatch.End (); Base.Draw (gameTime); }
I have this result:
// How far is the salary increase, each phantom is pulled from private zeros DrawEvenlySpacedSprites (Texture2D Texture, Vect 2 point 1, vector 2 point 2, float inchargement) {Var distance = vector 2. distribution (point 1, point 2); // Distance between two points repetition = (int) (distance / increment); // How many normalizedIncrement = 1.0f / iterations; // in the Lerp method requires values between 0.0 and 1.0 var amount = 0.0f; // sure that if it is necessary, but to make sure For that at least one // spread is prepared if two points are very close (iferati Ons == 0) iterations = 1; {Var drawpoint = vector2.larp (point1, point2, zodiac) for (int i = 0; i & lt; iterative; i ++); _spriteBatch.Draw (Texture, Draw, Color White); Zodiac + = normalized increase; }}
Then change your update method like this:
Private vector 2? _previousPoint; Protected Override Zero Update (Game Time Game Time) {Touch Touch Touch = Touchpanel. Gatestate (); Foreign (Touch touch in touch) {if (touch.State == TouchLocationState.Moved) {GraphicsDevice.SetRenderTarget (renderTarget); _spriteBatch.Begin (); If (_previousPoint.HasValue) DrawEvenlySpacedSprites (Texture, _previousPoint.Value, touch.Position, 0.5f); _spriteBatch.End (); GraphicsDevice.SetRenderTarget (zero); }} If (touches any.)) _previousPoint = touches. (Previous). Event; Else _previousPoint = null; Base.Update (gameTime); }
It should attract uniformly positioned sprites between each touch point which you are seeing and without surrender (which you can not actually do anyway) Without it.
I know how it goes .. Good luck :)
Comments
Post a Comment