天天看點

随便讀讀: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_;

}

選用哪種真的很重要麼?

繼續閱讀