Swift game Development Tetris: No.10 the last step! Beautify your Program

Source: Internet
Author: User

Well, this section is the last of our series of tutorials. After the previous code honed, to the last step, basically there is no too much knowledge points and difficulties. Finally, our program looks very cool:


As you can see from the graph, we add scores and levels, and then add animations that eliminate blocks, and actually sound. There is no small excitement ah, we start this.


First make sure that your attributes are consistent with the diagram.

We find the view from the lower right corner, then drag him into the screen, then set the background of the property to default, which is transparent, and then set it according to the coordinates and size of the diagram.


Next we drag in an image view, because the image is inside the view, so set it to 0, 0, then set the length and width of the view consistent, that is, completely overwrite, and then set the image to Whitebg.png


Then we add the label, the coordinates are 7,20 70, 21, and then modify the other properties as shown. If the font cannot be found, please select Custom


Next we make a copy of the newly built label, with coordinates set to 0, 45, and long width set to 84,39. So our interface looks like this.


So we've written the score view, and then we'll copy the view, select the entire view, and then copy. Set the location to 224,237. and modify the score and level font to the following color



Finally, our panel looks like this.


Then we'll set the outlet to two score label. That's roughly the case.


Then repeat the same step for another 999 label, named Levellabel, so run the next program, the interface should look like this


Then we begin to write the code, let's do an animation of the elimination.



The elimination of the action itself is not complicated, but the complication is that we have to calculate an angle to each block


Next we're going to add a sound



Finally, let's put these together in tandem to make our cool game.

We associate scores and levels with our interface.

When the program ends, play the end of the sound, and then start the new game.

Of course, we can also do more functions, such as adding a button, the click will not start again.


This is part of the game level upgrade, the falling interval will be shorter, the game is more difficult




OK, all the parts have been finished, enjoy your game!!



Swift game Development Tetris: No.10 the last step! Beautify your Program

Related Article

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.