/// <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); } } }
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); }
protected internal virtual void AddLayer(ActorLayer g) { }
internal void SetLayer(ActorLayer g) { this.gameLayer = g; }
internal void SetLayer(ActorLayer g) { this.gameLayer = g; }
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); }
protected internal virtual void AddLayer(ActorLayer g) { }
protected override void AddLayer(ActorLayer layer) { this.x = this.GetX(); this.y = this.GetY(); }
// 首次注入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); }
public MoveAction(MoveTo move, ActorLayer layer) { this.move = move; this.layer = layer; }
protected override void AddLayer(ActorLayer layer) { // 让角色渐进式出现 FadeTo fade = FadeOut(); fade.SetActionListener(new RotationAction()); }