繁体   English   中英

游戏运行时,将标签从一个位置统一移动到另一位置

[英]Move label from one position to another in unity when the game is running

我正在Unity中制作一个简单的2D游戏。 我有两个标签,一个显示当前得分,另一个显示高分。 游戏运行时,我可以将这些标签从一个位置移动到另一个位置吗? 我想要一个“跳入”效果。 希望你们能提供帮助。

    public void ShowEndScore(Font font, float coins, int highscore)
    {
        GUIStyle style = new GUIStyle();
        style.fontSize = 150;
        style.fontStyle = FontStyle.Bold;
        style.normal.textColor = Color.yellow;
        style.alignment = TextAnchor.UpperCenter;
        style.font = font;


        GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 2 - 50,     100, 50), "Your score: "+ coins, style);
        GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 2, 100, 50), "Highscore: "+ highscore, style);
    } 

您正在使用哪个版本的Unity?

我建议使用4.6 UI系统(因此使用4.6或更高版本),只需通过脚本更改文本的位置,甚至可以为“跳转”设置动画。

您可以在此处找到有关新UI和动画的不错的教程:

http://www.raywenderlich.com/78675/unity-new-gui-part-1

希望对您有所帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM