Ejemplo n.º 1
0
            public override void Draw(DrawCtx ctx, int g)
            {
                if (g < 0)
                {
                    g = ctx.NewGroup();
                }

                if (!hasShadow)
                {
                    for (int i = 0; i < charInfoCount; i += 1)
                    {
                        var b = ctx.GetBatch(shader, charInfos[i].texture, g);
                        b.DrawQuad(charInfos[i].quad, charInfos[i].uvQuad, color);
                    }
                }
                else
                {
                    for (int i = 0; i < charInfoCount; i += 1)
                    {
                        var b = ctx.GetBatch(shader, charInfos[i].texture, g);
                        b.DrawQuad(charInfos[i].quad + shadowPos, charInfos[i].uvQuad, shadowColor);
                        b.DrawQuad(charInfos[i].quad, charInfos[i].uvQuad, color);
                    }
                }
            }
Ejemplo n.º 2
0
 void OnDisable()
 {
     Res.ReleaseAtlases(10);
     DrawCtx.Dispose();
     if (gpc != null)
     {
         gpc.Dispose();
     }
 }
Ejemplo n.º 3
0
        public static void Draw(TpSprite *self, float *parentMat, bool isParentTransformDirty)
        {
                        #if FDB
            Should.NotNull("self", self);
            Should.TypeEqual("self", self->type, Type);
            Should.NotNull("self->spriteMeta", self->spriteMeta);
                        #endif
            var bat = DrawCtx.GetBatch(self->spriteMeta->atlas->name);
            int vertIdx = bat.vertCount, triIdx = bat.triCount;
            bat.RequestQuota(4, 6);

            float *verts = self->verts;
            float *uvs   = self->uvs;

            if (self->isTransformDirty)
            {
                float *mat = stackalloc float[6];
                Mat2D.FromScalingRotationTranslation(mat, self->pos, self->scl, self->rot);
                TpSpriteMeta.FillQuad(self->spriteMeta, mat, self->verts);
            }

            var   bVerts = bat.verts; var bUvs = bat.uvs;
            float z = self->pos[2];
            bVerts[vertIdx].Set(verts[0], verts[1], z);
            bVerts[vertIdx + 1].Set(verts[2], verts[3], z);
            bVerts[vertIdx + 2].Set(verts[4], verts[5], z);
            bVerts[vertIdx + 3].Set(verts[6], verts[7], z);

            bUvs[vertIdx].Set(uvs[0], uvs[1]);
            bUvs[vertIdx + 1].Set(uvs[2], uvs[3]);
            bUvs[vertIdx + 2].Set(uvs[4], uvs[5]);
            bUvs[vertIdx + 3].Set(uvs[6], uvs[7]);

            float *color   = self->color;
            var    bColor  = Vec4.Color(color, 0.5f);
            var    bColors = bat.colors;
            bColors[vertIdx]     = bColor;
            bColors[vertIdx + 1] = bColor;
            bColors[vertIdx + 2] = bColor;
            bColors[vertIdx + 3] = bColor;

            var bTris = bat.tris;
            bTris[triIdx]     = vertIdx;
            bTris[triIdx + 1] = vertIdx + 1;
            bTris[triIdx + 2] = vertIdx + 2;
            bTris[triIdx + 3] = vertIdx;
            bTris[triIdx + 4] = vertIdx + 2;
            bTris[triIdx + 5] = vertIdx + 3;
        }
Ejemplo n.º 4
0
 public abstract void Draw(DrawCtx ctx, int g);
Ejemplo n.º 5
0
            public override void Draw(DrawCtx ctx, int g)
            {
                var b = ctx.GetBatch(shader, texture);

                b.DrawQuad9Sliced(quad, quadInner, uvQuad, uvQuadInner, color, fillInner);
            }
Ejemplo n.º 6
0
    void OnEnable()
    {
        Res.LoadAtlases(10);

                #if GPC_TEST
        nodePool = Pool.New();

        nodeLst = PtrLst.New();
        PtrLst.Push(&nodePool->dependentLst, nodeLst);

        var sprite = (TpSprite *)Pool.Alloc(nodePool, sizeof(TpSprite));
        TpSprite.Init(sprite, Res.GetSpriteMeta(10001));

        var container = (Group *)Pool.Alloc(nodePool, sizeof(Group));
        Group.Init(container);
        PtrLst.Push(&nodePool->dependentLst, &container->childLst);

        PtrLst.Push(nodeLst, sprite);
        Vec4.Set(sprite->color, 1, 1, 1, 1);
        Vec2.Set(sprite->scl, .015f, .015f);

        DrawCtx.Start();
        var arr = (TpSprite **)nodeLst->arr;
        for (int i = 0, len = nodeLst->count; i < len; i += 1)
        {
            Node.Draw(arr[i], null, false);
        }
        DrawCtx.Finish();

        return;
                #endif

        gpc = new GpController(Camera.main);

        for (int i = 0; i < 5; i += 1)
        {
            gpc.SetCamAttr(CamAttr.Position, 0f, 0f);
            gpc.SetCamAttr(CamAttr.Zoom, 5f);

            gpc.AddImg(1, 10001);
            gpc.SetImgInteractable(1, (phase, x, y) => Debug.LogFormat("hit img1: phase {0}, x {1}, y {2}", phase, x, y));
            gpc.SetImgAttr(1, ImgAttr.Position, 0f, 0f, 0f);
            gpc.SetImgAttr(1, ImgAttr.Rotation, 0f);
            gpc.SetImgAttr(1, ImgAttr.Alpha, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Scale, 1f, EsType.ElasticOut, 0.01f, 0.01f);
            gpc.Wait(.5f);
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1.5f, EsType.ElasticOut, 1f, 0.5f, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Position, 2f, EsType.ElasticOut, 2f, -1f, 0f);
            gpc.Wait();
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1.5f, EsType.ElasticOut, 1f, 1f, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Position, 2f, EsType.ElasticOut, -2f, 2f, 0f);
            gpc.SetImgAttrEased(1, ImgAttr.Rotation, 1.5f, EsType.ElasticOut, Mathf.PI * 2.5f);

            gpc.SetCamAttrEased(CamAttr.Zoom, 1.5f, EsType.ElasticOut, 2f);
            gpc.SetCamAttrEased(CamAttr.Position, 2f, EsType.ElasticOut, -2f, 2f);

            gpc.Wait(.5f);
            gpc.AddImg(2, 10001);
            gpc.SetImgInteractable(2, (phase, x, y) => Debug.LogFormat("hit img2: phase {0}, x {1}, y {2}", phase, x, y));
            gpc.SetImgAttr(2, ImgAttr.Position, 0f, 0f, -5f);
            gpc.SetImgAttr(2, ImgAttr.Rotation, 0f);
            gpc.SetImgAttr(2, ImgAttr.Scale, 0.1f, 0.1f);
            gpc.SetImgAttr(2, ImgAttr.Alpha, 1f);
            gpc.SetImgAttrEased(2, ImgAttr.Scale, 1f, EsType.ElasticOut, 0.006f, 0.006f);
            gpc.SetImgAttrEased(2, ImgAttr.Position, 4f, EsType.ElasticOut, -2f, 2f, 0f);

            gpc.SetImgInteractable(1, null);

            gpc.Wait();
            gpc.SetImgId(2, 103);

            gpc.Wait();
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1f, EsType.ElasticOut, 1.5f, 1.5f, 1.5f);

            gpc.Wait();
            gpc.RmImg(1);
            gpc.RmImg(2);
        }

        Application.targetFrameRate = Screen.currentResolution.refreshRate;

                #if FDB
        Fdb.Test();
                #endif
    }
Ejemplo n.º 7
0
            public override void Draw(DrawCtx ctx, int g)
            {
                var b = ctx.GetBatch(shader, texture);

                b.DrawQuad(quad, uvQuad, color);
            }