Exemplo n.º 1
0
        public ChainedLabel(ChainedLabel target, Scene scene, Plane3D parent, float alpha, int order)
            : base()
        {
            if (alpha != 0.0f)
            {
                alpha = Math.Lerp(0.2f, 1.0f, alpha);
            }

            FontMap     = LargeFontMap;
            HeightScale = scene.Camera.GetPixelSize();
            Color       = Math.Lerp(Colors.White, Colors.Grey60, alpha);

            VertexZ = 1.0f;

            Text = "Label.VertexZ=" + VertexZ;

            Shadow = new Label()
            {
                FontMap = LargeFontMap, Color = Colors.Grey05
            };
            Shadow.HeightScale = HeightScale;
            Shadow.Text        = Text;

            Target = target;

            Schedule((dt) =>

            {
                if (Target == null)
                {
                    // head node

                    this.Position = m_center + m_radius * new Vector2(FMath.Cos((float)Director.Instance.DirectorTime * 0.5f * 2.033f),
                                                                      FMath.Cos((float)Director.Instance.DirectorTime * 0.5f * 0.98033f + 0.5f));

                    Vector2 touch_pos = Director.Instance.CurrentScene.Camera.GetTouchPos();

                    // you can drag the Label

                    if (Input2.Touch00.Down)
                    {
                        if (Input2.Touch00.Press
                            // not that since we set VertexZ and have used a perspective in this particular test scene,
                            // the picking here won't be very precise
                            && this.IsWorldPointInsideContentLocalBounds(touch_pos))
                        {
                            m_dragged           = true;
                            m_drag_start        = touch_pos;
                            m_center            = this.Position;                          // this is our new position, we zero the cosine offset too
                            m_radius            = 0.0f;
                            m_drag_start_center = m_center;
                        }

                        if (m_dragged)
                        {
                            m_center = m_drag_start_center + (touch_pos - m_drag_start);
                            m_radius = 0.0f;
                        }
                    }
                    else
                    {
                        m_dragged = false;
                        m_radius += (m_radius_target - m_radius) * 0.001f;
                    }
                }
                else
                {
                    // follower node

                    this.Position += 0.08f * (Target.Position - this.Position);
                }

                this.Shadow.Position = this.Position;
            }
                     );

            parent.AddChild(Shadow, -1);
            parent.AddChild(this, order);
        }