当前位置: 首页>>代码示例>>C#>>正文


C# UVAnimation.BuildUVAnim方法代码示例

本文整理汇总了C#中UVAnimation.BuildUVAnim方法的典型用法代码示例。如果您正苦于以下问题:C# UVAnimation.BuildUVAnim方法的具体用法?C# UVAnimation.BuildUVAnim怎么用?C# UVAnimation.BuildUVAnim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UVAnimation的用法示例。


在下文中一共展示了UVAnimation.BuildUVAnim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 30);
        anim.name = "Arm";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(256, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 8, 30);
        anim.name = "Explode";
        anim.loopCycles = 1;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:35,代码来源:BombController.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1023));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15);
        anim.name = "Surprise";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:26,代码来源:ClamHortonsBitsController.cs

示例3: Start

    // Use this for initialization
    public override void Start()
    {
        base.Start();

        GetComponent<SimpleFollow>().enabled = false;
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:29,代码来源:DiverControllerYellow.cs

示例4: Start

 // Use this for initialization
 void Start()
 {
     sprite = spriteManager.AddSprite(this.gameObject,2,2,new Vector2(.5f,.5f), new Vector2(.25f, .5f), new Vector3(0,0,0), true);
     stabbing = new UVAnimation();
     stabbing.name="stabbing";
     stabbing.SetAnim(stabbing.BuildUVAnim(new Vector2(.5f,.5f),new Vector2(.25f,.5f),2,2,3,2));
     stabbing.loopCycles=-1; // makes animation loop infinitely
     stabbing.loopReverse = true; // makes animation go in reverse after it's completed
     sprite.AddAnimation(stabbing);
     sprite.PlayAnim("stabbing");
 }
开发者ID:harrisse,项目名称:AdventureTime,代码行数:12,代码来源:FinnTestStabbing.cs

示例5: CreateAnimation

	protected UVAnimation CreateAnimation(string animName, Vector2 startUVPos, Vector2 UVSize, int animCells, int loopCycles, bool pingPongAnim, float framerate){
		UVAnimation anim = new UVAnimation();
		anim.name = animName;
		anim.loopCycles = loopCycles;
		anim.framerate = framerate;
		if(pingPongAnim)
			anim.loopReverse = true;
		
		anim.BuildUVAnim(startUVPos, UVSize, spriteSheetCols, spriteSheetRows, animCells, framerate);		
		return anim;
	}
开发者ID:pravusjif,项目名称:PravusUnityTests,代码行数:11,代码来源:Totem.cs

示例6: DrawAnimation

	public void DrawAnimation() {
		// Put sprite on the client object
		GameObject totem = GameObject.Find("TotemMono");
		totem.renderer.enabled = false;
		Sprite totemSprite = spriteManager.AddSprite(totem, 1f, 1f, new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), Vector3.zero, false);
		
		// Set up animation
		UVAnimation anim = new UVAnimation();
		anim.name = "animation1";
		anim.loopCycles = -1;
		anim.framerate = framerate;
		
		anim.BuildUVAnim(new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), 2, 2, 4, framerate);
		
		// Prepare sprite
		totemSprite.AddAnimation(anim);
		totemSprite.PlayAnim("animation1");
	}
开发者ID:pravusjif,项目名称:PravusUnityTests,代码行数:18,代码来源:SceneSprites.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        width = collider.bounds.size.x * 2 + 0.15f;
        height = collider.bounds.size.y * 2 + 0.15f;

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 11, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:19,代码来源:MineController.cs

示例8: Start

    // Use this for initialization
    void Start()
    {
        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 10, 15);
        anim.name = "Idle";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);
        sprite.PlayAnim("Idle");

        sprite.SetAnimCompleteDelegate(delegate()
        {
            Destroy(transform.parent.gameObject);
        });
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:21,代码来源:BubbleBurstController.cs

示例9: InitAffectors

    protected List<Affector> InitAffectors(EffectNode node)
    {
        List<Affector> AffectorList = new List<Affector>();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            if (UVType == 1)
            {
                float perWidth = OriUVDimensions.x / Cols;
                float perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                Vector2 cellSize = new Vector2(perWidth, perHeight);
                uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
            }
            UVDimension = uvAnim.UVDimensions[0];
            UVTopLeft = uvAnim.frames[0];

            if (uvAnim.frames.Length != 1)
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                AffectorList.Add(aft);
            }
        }
        else
        {
            UVDimension = OriUVDimensions;
            UVTopLeft = OriTopLeftUV;
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve, node);
            else
                aft = new RotateAffector(DeltaRot, node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;

            if (UseSameScaleCurve)
                ScaleYCurve = ScaleXCurve;

            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve, ScaleYCurve, node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable /*&& ColorAffectType != 0*/)
        {
            ColorAffector aft = new ColorAffector(this, node);
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMag,JetMagType,JetCurve,node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            aft = new VortexAffector(VortexObj, VortexMagType, VortexMag, VortexCurve, VortexDirection, VortexInheritRotation, node);

            AffectorList.Add(aft);
        }
        if (UVRotAffectorEnable)
        {
            Affector aft;

            float xscroll = UVRotXSpeed;
            float yscroll = UVRotYSpeed;
            if (RandomUVRotateSpeed)
            {
                xscroll = Random.Range(UVRotXSpeed,UVRotXSpeedMax);
                yscroll = Random.Range(UVRotYSpeed,UVRotYSpeedMax);
            }

            aft = new UVRotAffector(xscroll, yscroll, node);
            AffectorList.Add(aft);
        }

        if (GravityAffectorEnable)
        {
            Affector aft;
            aft = new GravityAffector(GravityObject, GravityAftType, GravityMagType, IsGravityAccelerate,GravityDirection, GravityMag, GravityCurve, node);
            AffectorList.Add(aft);

            if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
            {
                Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self:" + gameObject.name);
                GravityObject = transform;
            }

        }
        if (AirAffectorEnable)
        {
//.........这里部分代码省略.........
开发者ID:sylafrs,项目名称:rugby,代码行数:101,代码来源:EffectLayer.cs

示例10: InitAffectors

    protected ArrayList InitAffectors(EffectNode node)
    {
        ArrayList AffectorList = new ArrayList();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            if (UVType == 1)
            {
                float perWidth = OriUVDimensions.x / Cols;
                float perHeight = Mathf.Abs(OriUVDimensions.y / Rows);
                Vector2 cellSize = new Vector2(perWidth, perHeight);
                uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows);
            }
            UVDimension = uvAnim.UVDimensions[0];
            UVTopLeft = uvAnim.frames[0];

            if (uvAnim.frames.Length != 1)
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame);
                AffectorList.Add(aft);
            }
        }
        else
        {
            UVDimension = OriUVDimensions;
            UVTopLeft = OriTopLeftUV;
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve, node);
            else
                aft = new RotateAffector(DeltaRot, node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;
            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve, ScaleYCurve, node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable && ColorAffectType != 0)
        {
            ColorAffector aft;
            if (ColorAffectType == 2)
            {
                Color[] carr = new Color[5];
                carr[0] = Color1; carr[1] = Color2; carr[2] = Color3; carr[3] = Color4; carr[4] = Color5;
                aft = new ColorAffector(carr, ColorGradualTimeLength, ColorGradualType, node);
            }
            else
            {
                Color[] carr = new Color[2];
                carr[0] = Color1; carr[1] = Color2;
                aft = new ColorAffector(carr, ColorGradualTimeLength, ColorGradualType, node);
            }
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMin, JetMax, node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            aft = new VortexAffector(VortexObj, VortexMagType, VortexMag, VortexCurve, VortexDirection, VortexInheritRotation, node);

            AffectorList.Add(aft);
        }
        if (UVRotAffectorEnable)
        {
            Affector aft;
            aft = new UVRotAffector(UVRotXSpeed, UVRotYSpeed, node);
            AffectorList.Add(aft);
        }

        if (GravityAffectorEnable)
        {
            Affector aft;
            aft = new GravityAffector(GravityObject, GravityAftType, GravityMagType, IsGravityAccelerate,GravityDirection, GravityMag, GravityCurve, node);
            AffectorList.Add(aft);

            if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null)
            {
                Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self.");
                GravityObject = transform;
            }

        }
        if (AirAffectorEnable)
        {
            Affector aft = new AirFieldAffector(AirObject, AirDirection, AirMagType, AirMagnitude, AirMagCurve, AirAttenuation, AirUseMaxDistance,
//.........这里部分代码省略.........
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:101,代码来源:EffectLayer.cs

示例11: InitAffectors

    protected ArrayList InitAffectors(EffectNode node)
    {
        ArrayList AffectorList = new ArrayList();

        if (UVAffectorEnable)
        {
            UVAnimation uvAnim = new UVAnimation();
            Texture t = Vertexpool.GetMaterial().GetTexture("_MainTex");

            if (UVType == 2)
            {
                uvAnim.BuildFromFile(EanPath, EanIndex, UVTime, t);
                OriLowerLeftUV = uvAnim.frames[0];
                OriUVDimensions = uvAnim.UVDimensions[0];
            }
            else if (UVType == 1)
            {
                float perWidth = t.width / Cols;
                float perHeight = t.height / Rows;
                Vector2 cellSize = new Vector2(perWidth / t.width, perHeight / t.height);
                Vector2 start = new Vector2(0f, 1f);
                uvAnim.BuildUVAnim(start, cellSize, Cols, Rows, Cols * Rows);
                OriLowerLeftUV = start;
                OriUVDimensions = cellSize;
                OriUVDimensions.y = -OriUVDimensions.y;
            }

            if (uvAnim.frames.Length == 1)
            {
                OriLowerLeftUV = uvAnim.frames[0];
                OriUVDimensions = uvAnim.UVDimensions[0];
            }
            else
            {
                uvAnim.loopCycles = LoopCircles;
                Affector aft = new UVAffector(uvAnim, UVTime,node);
                AffectorList.Add(aft);
            }
        }

        if (RotAffectorEnable && RotateType != RSTYPE.NONE)
        {
            Affector aft;
            if (RotateType == RSTYPE.CURVE)
                aft = new RotateAffector(RotateCurve,node);
            else
                aft = new RotateAffector(DeltaRot,node);
            AffectorList.Add(aft);
        }
        if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE)
        {
            Affector aft;
            if (ScaleType == RSTYPE.CURVE)
                aft = new ScaleAffector(ScaleXCurve,ScaleYCurve,node);
            else
                aft = new ScaleAffector(DeltaScaleX, DeltaScaleY,node);
            AffectorList.Add(aft);
        }
        if (ColorAffectorEnable && ColorAffectType != 0)
        {
            ColorAffector aft;
            if (ColorAffectType == 2)
            {
                Color[] carr = new Color[4];
                carr[0] = Color1; carr[1] = Color2; carr[2] = Color3; carr[3] = Color4;
                aft = new ColorAffector(carr,ColorGradualTimeLength,ColorGradualType,node);
            }
            else
            {
                Color[] carr = new Color[2];
                carr[0] = Color1; carr[1] = Color2;
                aft = new ColorAffector(carr,ColorGradualTimeLength,ColorGradualType,node);
            }
            AffectorList.Add(aft);
        }
        if (LinearForceAffectorEnable)
        {
            Affector aft = new LinearForceAffector(LinearForce.normalized * LinearMagnitude,node);
            AffectorList.Add(aft);
        }
        if (JetAffectorEnable)
        {
            Affector aft = new JetAffector(JetMin,JetMax,node);
            AffectorList.Add(aft);
        }
        if (VortexAffectorEnable)
        {
            Affector aft;
            if (UseVortexCurve)
                aft = new VortexAffector(VortexCurve, VortexDirection,node);
            else
                aft = new VortexAffector(VortexMag, VortexDirection,node);
            AffectorList.Add(aft);
        }
        if (AttractionAffectorEnable)
        {
            Affector aft ;
            if (UseVortexCurve)
                aft = new AttractionForceAffector(AttractionCurve, AttractionPosition,node);
            else
//.........这里部分代码省略.........
开发者ID:zi-su,项目名称:React,代码行数:101,代码来源:EffectLayer.cs

示例12: Start

    void Start()
    {
        spriteManager = spriteManagerObject.GetComponent<SpriteManager>();

        bullets = new Bullet[numberOfBullets];
        for(int i = 0; i < numberOfBullets; i++)
        {
            Bullet bullet = new Bullet();
            Rigidbody brigidbody = Instantiate(bulletPrefab, Vector3.zero, Quaternion.identity) as Rigidbody;
            brigidbody.transform.parent = transform;
            brigidbody.gameObject.SetActive(false);
            bullet.rigidbody = brigidbody;

            bullet.sprite = spriteManager.AddSprite(bullet.rigidbody.gameObject, 2f, 2f, 0, 512, 512, 512, true);

            UVAnimation animation = new UVAnimation();
            Vector2 randomFacingUV = (UnityEngine.Random.value >= 0.5f) ? new Vector2(0, 0.5f) : new Vector2(0.5f, 0);
            animation.BuildUVAnim(randomFacingUV, new Vector2(0.5f, 0.5f), 2, 1, 2, 8);
            animation.loopCycles = 3000;
            bullet.sprite.PlayAnim(animation);
            spriteManager.AnimateSprite(bullet.sprite);

            bullets[i] = bullet;
        }

        GameManager.RegisterPlayer(gameObject);

        swarm = swarmObject.GetComponent<SwarmScript>();
    }
开发者ID:kot-behemoth,项目名称:sgj13,代码行数:29,代码来源:PlayerScript.cs

示例13: Start

    public override void Start()
    {
        base.Start();

        sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);

        // Create and setup anims
        UVAnimation anim = new UVAnimation();
        var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
        var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
        anim.name = "Idle";
        anim.loopCycles = -1;

        sprite.AddAnimation(anim);

        anim = new UVAnimation();
        firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
        cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
        anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
        anim.name = "Die";
        anim.loopCycles = 0;

        sprite.AddAnimation(anim);

        sprite.PlayAnim("Idle");

        dolphin = GameObject.Find("DolphinSprite");
        Util.Assert(dolphin != null);
    }
开发者ID:svermeulen,项目名称:HalifaxGameJam2012,代码行数:30,代码来源:DiverControllerRed.cs

示例14: InitSM

    void InitSM()
    {
        S = LSM.AddSprite(this.gameObject, 5, 5, LSM.PixelCoordToUVCoord(0, 0), LSM.PixelSpaceToUVSpace(512, 512), -transform.forward * .4f, false);
        anim_run = new UVAnimation();
        anim_run.SetAnim(
            new Vector2[]{
                LSM.PixelCoordToUVCoord(3072, 0),
                LSM.PixelCoordToUVCoord(3072+512, 0),
                LSM.PixelCoordToUVCoord(0, 512),
                LSM.PixelCoordToUVCoord(512, 512),
                LSM.PixelCoordToUVCoord(1024, 512),
                LSM.PixelCoordToUVCoord(1024+512, 512),
                LSM.PixelCoordToUVCoord(2048, 512),
                LSM.PixelCoordToUVCoord(2048+512, 512)
            });
        //anim_run.BuildUVAnim(LSM.PixelCoordToUVCoord(3072, 512), LSM.PixelSpaceToUVSpace(512, 512), 16, 2, 16, 2f);
        anim_run.loopCycles = -1;
        //anim_run.PlayInReverse();
        anim_run.name = "Run";
        S.AddAnimation(anim_run);

        anim_idle = new UVAnimation();
        anim_idle.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f);
        anim_idle.loopCycles = -1;
        S.AddAnimation(anim_idle);
        anim_idle.name = "Idle";

        anim_runstart = new UVAnimation();
        anim_runstart.BuildUVAnim(LSM.PixelCoordToUVCoord(0, 512), LSM.PixelCoordToUVCoord(512, 512), 8, 2, 1, 12f);
        anim_runstart.loopCycles = -1;
        S.AddAnimation(anim_runstart);
        anim_runstart.name = "RunStart";

        anim_current = "Run";
        S.PlayAnim(anim_run);
        LSM.ScheduleBoundsUpdate(0.5f);
    }
开发者ID:andrei-livadariu,项目名称:ClimbBobClimb,代码行数:37,代码来源:Playorz.cs

示例15: Initialize

    public void Initialize(DungeonEntity e, SpriteData sd, LinkedSpriteManager ls)
    {
        entity = e;
        spriteData = sd;
        lsManager = ls;
        Texture texture = lsManager.material.mainTexture;
        Vector2 textDim = new Vector2(texture.width, texture.height);
        uvDim = new Vector2(spriteData.spriteDim.x / textDim.x, spriteData.spriteDim.y / textDim.y);
        Vector2 uvCoord = Vector2.zero;
        uvCoord.x = uvDim.x * 7;
        uvCoord.y = 1 - (spriteData.spriteDim.y * (spriteData.spriteIndex + 1) / textDim.y);
        sprite = lsManager.AddSprite(gameObject, spriteData.dim.x, spriteData.dim.y, uvCoord, uvDim, Vector3.up * 0.5f, true);
        visible = true;

        transform.localPosition = Vector3.up * sd.dim.y/2;

        Vector2 pos;

        UVAnimation walking_s = new UVAnimation();
        pos = new Vector2(0, uvCoord.y);
        walking_s.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_s.name = "walking_s";
        walking_s.loopCycles = -1;

        UVAnimation walking_nw = new UVAnimation();
        pos = new Vector2(uvDim.x * 3, uvCoord.y);
        walking_nw.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_nw.name = "walking_nw";
        walking_nw.loopCycles = -1;

        UVAnimation walking_sw = new UVAnimation();
        pos = new Vector2(uvDim.x * 3, uvCoord.y);
        walking_sw.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_sw.name = "walking_sw";
        walking_sw.loopCycles = -1;

        UVAnimation walking_ne = new UVAnimation();
        pos = new Vector2(uvDim.x * 6, uvCoord.y);
        walking_ne.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_ne.name = "walking_ne";
        walking_ne.loopCycles = -1;

        UVAnimation walking_se = new UVAnimation();
        pos = new Vector2(uvDim.x * 6, uvCoord.y);
        walking_se.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_se.name = "walking_se";
        walking_se.loopCycles = -1;

        UVAnimation walking_n = new UVAnimation();
        pos = new Vector2(uvDim.x * 9, uvCoord.y);
        walking_n.BuildUVAnim(pos, uvDim, 3, 1, 3, 10);
        walking_n.name = "walking_n";
        walking_n.loopCycles = -1;

        sprite.AddAnimation(walking_n);
        sprite.AddAnimation(walking_ne);
        sprite.AddAnimation(walking_nw);
        sprite.AddAnimation(walking_s);
        sprite.AddAnimation(walking_se);
        sprite.AddAnimation(walking_sw);
    }
开发者ID:cindyxu,项目名称:soulstrand,代码行数:61,代码来源:EntitySprite.cs


注:本文中的UVAnimation.BuildUVAnim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。