Example #1
0
        /// <summary>
        /// 矫正当前图像大小
        /// </summary>
        ///
        private void CalcBounds()
        {
            ActorLayer layer = this.GetLLayer();

            if (layer != null)
            {
                int width;
                int height;
                int cellSize = layer.GetCellSize();
                int minY     = 0;
                if (this.image == null)
                {
                    width             = location.X() * cellSize + cellSize;
                    height            = location.Y() * cellSize + cellSize;
                    this.boundingRect = new RectBox(width, height, 0, 0);
                    for (minY = 0; minY < 4; ++minY)
                    {
                        this.xs[minY] = width;
                        this.ys[minY] = height;
                    }
                }
                else
                {
                    this.boundingRect = MathUtils.GetBounds(location.x,
                                                            location.y, this.image.GetWidth(),
                                                            this.image.GetHeight(), rotation);
                }
            }
        }
Example #2
0
 internal void AddLayer(float x, float y, ActorLayer g)
 {
     if (g.IsBounded())
     {
         x = this.LimitValue(x, g.GetWidth() - GetWidth());
         y = this.LimitValue(y, g.GetHeight() - GetHeight());
     }
     this.boundingRect = null;
     this.SetLayer(g);
     this.SetLocation(x, y);
 }
Example #3
0
 protected internal virtual void AddLayer(ActorLayer g)
 {
 }
Example #4
0
 internal void SetLayer(ActorLayer g)
 {
     this.gameLayer = g;
 }
Example #5
0
 internal void SetLayer(ActorLayer g)
 {
     this.gameLayer = g;
 }
Example #6
0
 internal void AddLayer(float x, float y, ActorLayer g)
 {
     if (g.IsBounded())
     {
         x = this.LimitValue(x, g.GetWidth() - GetWidth());
         y = this.LimitValue(y, g.GetHeight() - GetHeight());
     }
     this.boundingRect = null;
     this.SetLayer(g);
     this.SetLocation(x, y);
 }
Example #7
0
 protected internal virtual void AddLayer(ActorLayer g)
 {
 }
Example #8
0
 protected override void AddLayer(ActorLayer layer)
 {
     this.x = this.GetX();
     this.y = this.GetY();
 }
Example #9
0
            // 首次注入Layer时调用此函数
            protected override void AddLayer(ActorLayer layer)
            {

                // 坐标矫正,用以让角色居于瓦片中心
                int offsetX = (GetLLayer().GetField2D().GetTileWidth() - this
                       .GetWidth()) / 2;
                int offsetY = (GetLLayer().GetField2D().GetTileWidth() - this
                       .GetHeight()) / 2;
                // 初始化角色在Layer中坐标
                SetLocation(startX + offsetX, startY + offsetY);
                // 命令角色向指定坐标自行移动(参数为false为四方向寻径,为true时八方向),并返回移动控制器
                // PS:endX与endY非显示位置,所以不必矫正
                MoveTo move = MoveTo(endX, endY, false);

                // 矫正坐标,让角色居中
                move.SetOffset(offsetX, offsetY);
                // 启动角色事件监听
                move.SetActionListener(new MoveAction(move, layer));
                // 设定移动速度
                move.SetSpeed(speed);
            }
Example #10
0
 public MoveAction(MoveTo move, ActorLayer layer)
 {
     this.move = move;
     this.layer = layer;
 }
Example #11
0
 protected override void AddLayer(ActorLayer layer)
 {
     // 让角色渐进式出现
     FadeTo fade = FadeOut();
     fade.SetActionListener(new RotationAction());
 }