Exemplo n.º 1
0
    private void SetSpritePrimitive(
        out SpritePrim spritePrim,
        SpriteB spriteB
        )
    {
        spritePrim.V0.Color = _color;
        spritePrim.V1.Color = _color;
        spritePrim.V2.Color = _color;
        spritePrim.V3.Color = _color;

        spritePrim.V0.UV = spriteB._uv[0];
        spritePrim.V1.UV = spriteB._uv[1];
        spritePrim.V2.UV = spriteB._uv[2];
        spritePrim.V3.UV = spriteB._uv[3];

        if (spriteB.Rotation == 0.0f)
        {
            spritePrim.V0.Position.X = (short)(spriteB.Position.X - spriteB.Width * spriteB.Center.X);           //0.0f;	// x0
            spritePrim.V0.Position.Y = (short)(spriteB.Position.Y - spriteB.Height * spriteB.Center.Y);          //0.0f;	// y0

            spritePrim.V1.Position.X = (short)(spriteB.Position.X - spriteB.Width * spriteB.Center.X);           //0.0f;	// x1
            spritePrim.V1.Position.Y = (short)(spriteB.Position.Y + spriteB.Height * (1.0f - spriteB.Center.Y)); //1.0f;	// y1

            spritePrim.V2.Position.X = (short)(spriteB.Position.X + spriteB.Width * (1.0f - spriteB.Center.X));  //1.0f;	// x2
            spritePrim.V2.Position.Y = (short)(spriteB.Position.Y - spriteB.Height * spriteB.Center.Y);          //0.0f;	// y2

            spritePrim.V3.Position.X = (short)(spriteB.Position.X + spriteB.Width * (1.0f - spriteB.Center.X));  //1.0f;	// x3
            spritePrim.V3.Position.Y = (short)(spriteB.Position.Y + spriteB.Height * (1.0f - spriteB.Center.Y)); //1.0f;	// y3
        }
        else
        {
            float x, y, rc, rs;

            rc = FMath.Cos(spriteB.Rotation);
            rs = FMath.Sin(spriteB.Rotation);

            x = -spriteB.Width * spriteB.Center.X;
            y = -spriteB.Height * spriteB.Center.Y;
            spritePrim.V0.Position.X = (short)(spriteB.Position.X + (float)(x * rc - y * rs));      // x0
            spritePrim.V0.Position.Y = (short)(spriteB.Position.Y + (float)(x * rs + y * rc));      // y0


            x = -spriteB.Width * spriteB.Center.X;
            y = spriteB.Height * (1.0f - spriteB.Center.Y);
            spritePrim.V1.Position.X = (short)(spriteB.Position.X + (float)(x * rc - y * rs));      // x1
            spritePrim.V1.Position.Y = (short)(spriteB.Position.Y + (float)(x * rs + y * rc));      // y1


            x = spriteB.Width * (1.0f - spriteB.Center.X);
            y = -spriteB.Height * spriteB.Center.Y;
            spritePrim.V2.Position.X = (short)(spriteB.Position.X + (float)(x * rc - y * rs));    // x2
            spritePrim.V2.Position.Y = (short)(spriteB.Position.Y + (float)(x * rs + y * rc));    // y2


            x = spriteB.Width * (1.0f - spriteB.Center.X);
            y = spriteB.Height * (1.0f - spriteB.Center.Y);
            spritePrim.V3.Position.X = (short)(spriteB.Position.X + (float)(x * rc - y * rs));    // x3
            spritePrim.V3.Position.Y = (short)(spriteB.Position.Y + (float)(x * rs + y * rc));    // y3
        }
    }
Exemplo n.º 2
0
    public void Add(SpriteB spriteB)
    {
        if (cnt >= m_maxNumOfSprite)
        {
            return;
        }

        this.spriteList.Add(spriteB);
        ++cnt;
    }