[Unity3D plugin] 2dtoolkit Series 2 animation genie creation and unlimited scrolling of background images

Source: Internet
Author: User

After the release of 2dtoolkit Series 1 yesterday, I feel that it has some inspiration for new users. I am guided to learn how to use the unity 2dToolKit plug-in. Today I will continue to create Series 2-animation genie, and the infinite loop scrolling of the background image. In the group, I always see what technologies are good and what technologies are not good. New users will always be confused about learning C #, java, cocos2d, and unity, I always think about things that are quite popular. In fact, there is no need to make a dilemma for myself. Everyone has a difficult choice, and don't want to eat a big cake, some people may say something very popular with you, but now, when you are a newbie, it may be replaced by new technologies. As long as it technology is used, you can definitely learn it, in fact, the technology is the same. It is the most important thing to learn ideas and learn how to solve problems! Let's talk about the content of today.

I. Take a look at the overall

Because CSDN is hard to upload Flash files, this is also a headache. Unlike other blogs, you can upload flash files to Display Dynamic results. This is uploaded to Baidu Image Library and dynamic files (click to view details ), I also see some frame pictures. I will see some changes in the details. The background is moving, and the wings of Xiaolong are shaking!



Look at the wings of Xiaolong and the position of the minor insects below. This shows that the background is moving and the dragon is moving! Wow!

Ii. Detailed production process 1. Prepare a series of sequence frame images

Sequence frame images are essential materials for animation production. Based on the series 1 tutorial, we learned how to create a sprite set. Similarly, before making a sequence Frame Animation, we still need to make a Genie set to put these sequence frame images into the sprite set.

Online demonstration: http: // 114.92.240.43/dingxiaowei/FlappyDragon.html



2. Create a sequence Frame Animation

1. Create an Animation folder under the Assets Directory-> right-click Create-> tk2d-> Sprite Animation



2. Click DragonAnimation-> open editor... to edit its attributes.


Then add an animated frame image to make the animation.


After creating all the animation frames, you can click Play to see the effect!

3. Create an Animation genie in the Hierarchy panel-> Create tk2d-> Sprite With Animation

Name it AnimatedDragonSprite, find the tk2dSpriteAnimator component, modify AnimLib, and select the animation you just created.

Then let's run it and we will find that the Game panel will show a little dragon that keeps shaking its wings. It's so cute, wow! I will not intercept it, just like above.
3. the infinite loop of the background is rolling in 2d game production. You will find a regular rule. Generally, the main character genie are fixed at a certain position on the screen, but it will also make you feel that it is moving, because this is the visual parallax. In fact, it is the background. However, you feel that the main character genie is moving, and 2d games are cleverly applied to this point, this is the relative motion in physics. The principle is to copy the same image and place the two together. One of the images serves as the background of the entire screen, and the other is in the just-entering area, then, when the first figure is about to exit the screen, change it to the second one on the right, so that round-robin can achieve the effect. Directly paste the Code:
Public float speed; private float movespeed; public float minPositionX; public float terPositionX; // Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {movespeed = speed * Time. deltaTime; transform. translate (Vector3.left * movespeed, Space. world); // move to the left if (transform. localPosition. x <minPositionX) {transform. localPosition = new Vector3 (terPositionX, transform. localPosition. y, transform. localPosition. z );}}

The Code is very simple. Then, drag and drop the script to the background image and run it to see the infinite scrolling of the background!

Reprinted please indicate the source: http://blog.csdn.net/dingxiaowei2013/article/details/20498037
Online demonstration: http: // 114.92.240.43/dingxiaowei/FlappyDragon.html

================================== Publisher Ding Xiaowei CSDN blog column ================ =====

MyBlog: http://blog.csdn.net/dingxiaowei2013 MyQQ: 1213250243

Unity QQ group: 375151422,858550, 6348968 cocos2dx QQ group: 280818155

==================================== Mutual learning, common progress ==============================




Immersed in blog writing, I had two minutes in the morning. I enjoyed this process and shared it with others. It seems that I am suitable for writing books. Wow, where can I publish my own books! This is a dream. Of course, I have recently provided my post on book editing, but I still enjoy the current process and enrich every day! It's time to wash and sleep. Continue tomorrow and study will never stop!

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.