天天看点

随便读读:Windows 游戏编程大师技巧 (第二版) 关于BOB

BOB (Blitter Object) 游戏引擎中的重要对象,代表由一系列动画组成的一个屏幕元素。让人想到图元……

BOB 的基本属性:

  • Position
  • Size
  • State : visible or invisible
  • Images or ImageFrames
  • Animations
  • Animation Speed
  • current animation
  • current image in current animation
  • Counter / Timer

BOB 的基本操作:

  • CreateBOB
  • DestoryBOB
  • SetImageFrames
  • AddAnimation
  • SetPosition / GetPosition
  • SetAnimationSpeed
  • Animate
  • SetCurrentAnimation
  • SetCurrentFrame
  • Show
  • Hide

可以看出,和 J2ME 中 Sprite 的抽象接近,不同的是 J 中的抽象更加多的加入了游戏对象,而不是图像元素的成分,例如碰撞检测。并且没有加入任何 Timer / Counter 仅仅是 nextFrame / prevFrame,故而没有类似于 Animate 的方法。

在 J 中对象的加速度等信息可以通过继承来实现,也可以通过上层封装。

class Bomb extends Sprite {

}

class Bomb {

    private Sprite sprite_;

}

选用哪种真的很重要么?