Juvenile Kingdoms Home Effect implementation

Source: Internet
Author: User

The first two days of our planning to achieve a "juvenile kingdoms" game in the lobby of the 3D rotation effect, probably this way: in the main interface, there are nine characters formed an oval area, sliding screen, you can slide the direction of the different can rotate around and the front will cover the back of the character card. I tried to use NGUI3.8 to implement this function. The main interface of "juvenile Kingdoms" is as follows:

Main idea: Use the angle of each point and X axis to calculate the position of the point on the screen. From the screen, enter the angle of the displacement control rotation, each frame calculates the position of the point. The problem of occlusion can be controlled using Widged's depth.
I have designed these two classes:
Ellipseplugin: Calculates an elliptical area for placing objects that need to be rotated. The location of these objects (Gameobject) is automatically generated (in fact, you can also set their own, for the convenience of the program, changed to automatic display)
Point: Each of the points on the ellipse (gameobject) updates its position each frame.

In the first step, we first realize the rotation of the elliptical region.
First, the elliptic equation is analyzed by using (x, Y) the long and short axes of the ellipse (a longer axis, b stub axis), the center point Coordinate (x0,y0) and the angle Sita = (x, y) = (x0 + A * cos (SITA), y0 + b * sin (SITA))
Then, we can build several classes as needed,
First control ellipse region and input processing ellipse
Class Members: Ellipse center point, long axis, short axis
class function: Ondrag (float delta) Converts the shift of the screen to the angle of the point (Gameobject) on the ellipse
Points on the second ellipse: Point
Class Member: Angle (Angle)
Class functions: Processing position changes per frame
The drag rotation can be achieved by the above method

My Beginner's

Next is to strengthen the implementation
Achieve scaling and occlusion
1. Zooming
Scaling is related to the y-coordinate of the point on the ellipse, or it can be calculated using the long and short axes and the rotation angle, the larger the Y coordinate, the smaller the display, the farther away the object feels.
2. Occlusion
You can use the depth implementation of the rendered depth widget, the larger the depth value, the more forward the rendering, and also the long and short axes and rotation angles of the ellipse can be used.
Code implementation is relatively simple, not on the code (my code is a bit confusing)
Finally, we want to animate that if you rotate to a point, when you release your finger, you want to use an animated way to dock the point at the front of the position.
The first thing to do is to calculate the stop, just calculate the angle between each point on the ellipse and the stop, get the point with the smallest angle, and set the animation to move. Since we use the angle for all the logic control, here by the angle to update the most convenient, set each frame to move a very small angle.
What I said above is a bit sketchy, if there is no implementation, can be discussed in the comments below.

As follows:

The scale here is adjustable.

After I realized, I found that the "Juvenile Kingdoms" implementation is not as thin as I thought, it in the beginning of the action decided the final direction of rotation, such as I just started to Zosch, when the mouse bounce, no matter which direction I go, it will slide to the left to the specified position.

Juvenile Kingdoms Home Effect implementation

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.