unity3d和下OrtHello的使用教程 (二) 移动物体,碰撞等

本教程回顾上一节内容,补充说明OT预设物体的用途,包括管理全局的OT物体、不同类型的Sprites以及如何创建动画。讲解了如何使用Animation目录设置序列帧动画,并指出Unity中物体的collior特性。同时,文章提供了一段C#代码作为示例。
摘要由CSDN通过智能技术生成

回顾一下上一次的教程orz,也许有许多地方没有说清楚的,我补充一下

首先是OT的预设物体有:

是不是看到了熟悉的Sprite等物体,首先OT这个物体是一定要一开始就拖到场景中了,它作为一个管理全局的OT物体而存在。

然后是Sprites,Sprites简单来说只有3种:不会自己主动动画的Sprite,会自己主动动画的AnimatingSprite,能填充一定区域范围的FilledSprite,这三种Sprite是直接放进场景中的,

Sprites目录下的Animation是根据SpriteAtlas或者是SpriteSheet的Texture来生成序列帧动画的,主要是设置从第几帧到第几帧是什么动画,这样子方便AnimatingSprite的调用,这些Animation就是放到场景中的OT下的Animation目录中的

Sprites目录下的SpriteAtlas和SpriteSheet都是用来管理Texture的,以后说。




话说,unity有一点我超不喜欢的就是:一个在场景中的物体带有collior 可我不知道是自己附上去的还是通过代码添加的orz


下面是附C#代码

public class CExample2 : MonoBehaviour {

    /// <exclude />
    public OTSprite blockPrototype; // prototype to create blocks
    /// <exclude />
    public OTSprite starPrototype;  // prototype to create stars

    bool initialized = false;       // initialization indicator

    // Create the objects of this demo using provided prototypes
    void CreateObjects()
    {
        // Find the empty that will act as the block container
        GameObject blocks = GameObject.Find("Blocks");
        if (blocks!=null)
        {
            // Calculate the horizontal number of blocks for the current resolution
            int c = (Screen.width - 20) / 85;
            // Calculate horizontal center spacing
            int s = (Screen.width - (c * 85)) / 2;
            // Create bottom horizontal blocks
            for (int x = 0; x < c; x++)
            {
                // Create a new block
                OTSprite b = (Instantiate(blockPrototype.gameObject) as GameObject).GetComponent<OTSprite>();
                // Set block's position
                b.position = new Vector2(s + 50 + (x * 85)- (Screen.width/2), 20 - (Screen.height/2));
                // Set block's name
                b.name = "bottom" + x;
                // Link to parent
                b.transform.parent = blocks.transform;
            }
            // Create top horizontal blocks
            for (int x = 0; x < c; x++)
            {
                // Create a new block
                OTSprite b = (Instantiate(blockPrototype.gameObject) as GameObject).GetComponent<OTSprite>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值