XNa development-add some highlights

Source: Internet
Author: User

Undoubtedly, the square to be rotated involves only the basic content in xNa. Now, the project is simply modified to make the displayed images more vivid and attractive.

PressCodeTo modify the code of the draw function, you will see a major change in the drawing on the screen.

Protected override void draw (gametime)
{
Graphicsdevice. Clear (color. cornflowerblue );
// Reset the world Matrix
_ Effect. World = matrix. identity;
// Loop for each square
For (INT I = 0; I <20; I ++)
{
Foreach (effectpass pass in _ effect. currenttechnique. Passes)
{
// Apply a further Rotation
_ Effect. World = matrix. createrotationz (_ angle) * _ effect. World;
// Scale the object so that it is shown slightly smaller
_ Effect. World = matrix. createscale (0.85f) * _ effect. World;
// Apply the pass
Pass. Apply ();
// Draw the square
Graphicsdevice. drawuserprimitives (primitivetype. trianglestrip, _ vertices, 0, 2 );
}
}
Base. Draw (gametime );
}

Unfortunately, the screen cannot reflect the real running effect of the project. Although the dynamic content must be much better than the static image, this method of using short code blocks to generate results is very good.

In the loop, 20 shapes are drawn, each of which is slightly smaller than the previous one and rotated to a different angle. The scaling and rotation operations are accumulative, which means that the first (largest) Square is rotated at the specified angle _ angle, then the second square is rotated twice the angle, and the third is rotated three times the angle, and so on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.