コード例 #1
0
    public void Start()
    {
        if (size.x == 0) {
            size.x = background.GetComponent<SpriteRenderer>().bounds.size.x;
        }
        if (size.y == 0) {
            size.y = background.GetComponent<SpriteRenderer>().bounds.size.y;
        }

        MovingLayerPart mainSprite = new MovingLayerPart();
        mainSprite.SetSprite(background);
        mainSprite.SetSize(size);
        __parts.Add(mainSprite);

        __sign.x = speed.x < 0 ? 1 : -1;
        __sign.y = speed.y < 0 ? 1 : -1;

        if (speed.y != 0) {
            __SetClone(0, size.y, "vertical");
        }

        if (speed.x != 0) {
            __SetClone(size.x, 0, "horisontal");
        }

        if (speed.x != 0 && speed.y != 0) {
            __SetClone(size.x, size.y, "diagonal");
        }

        foreach (MovingLayerPart part in __parts) {
            part.Start();
        }
    }
コード例 #2
0
 private void __SetClone(float sizeX = 0, float sizeY = 0, string name = "")
 {
     MovingLayerPart verticalSprite = new MovingLayerPart();
     Transform verticalSpriteTransform = Transform.Instantiate(background) as Transform;
     verticalSpriteTransform.transform.parent = background.transform.parent;
     verticalSpriteTransform.transform.name = background.transform.name + " " + name + " clone";
     verticalSprite.SetSprite(verticalSpriteTransform);
     verticalSprite.SetDelta(new Vector2(sizeX * __sign.x, sizeY * __sign.y));
     verticalSprite.SetSize(size);
     __parts.Add(verticalSprite);
 }