Coffee2D HTML5 游戏引擎

程序名称:Coffee2D

授权协议: MIT

操作系统: 跨平台

开发语言: JavaScript

Coffee2D 介绍

Coffee2D 是一个 HTML5 游戏引擎,它将开发 HTML5 Canvas 游戏中大量的工作抽象出来,例如 CoffeeScript 特性(如
class 关键字)来更好的与游戏和 CoffeeScript 集成。

Coffee2D 当前提供:

  • 简单场景图

  • 精灵渲染

  • 事件处理

  • 动画

  • Isometric 地图

组件:

class Card extends Component
  constructor: (@suit, @value) ->
    super()
    @setSize(50, 80)
    # the rectangle will be drawn automatically
    @addChild new Rect 0, 0, @size.w, @size.h, 'white'

  update: (dt) ->
    # dt is delta time passed since last update
    # (update stuff...)
    super()

  draw: (ctx) ->
    # ctx is the canvas context associated with this scene
    # (draw additional stuff other than the rectangle...)
    super()

事件处理:

# event origin is automatically set to unit
unit.dispatchEvent {type: 'kill', target: enemy}
enemy.addListener 'kill', (evt) -> if evt.target == enemy then enemy.die()

# can also fire events from Event class, origin will not be set
Event.dispatchEvent {type: 'init'}

Coffee2D 官网

https://github.com/LanJian/coffee2d

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。