Hilo Game Framework

repository·dev·Indexed 26 days ago

https://github.com/hiloteam/hilo

A cross-platform HTML5 game development framework developed by Alibaba Group. Hilo provides an object-oriented programming environment with support for multiple rendering engines including Canvas, DOM, and WebGL. It features independent module design (CMD, AMD, CommonJS, KMD), integration with Chipmunk for physics and DragonBones for skeletal animation, and a Yeoman generator for project scaffolding.

Tokens
2.6K
Snippets
7
Records
28
Agent score
91%

What's inside Hilo

  1. Overview of Hilo features

    dev

    Hilo is an HTML5 cross-terminal game solution developed by Alibaba. Key features include:

    • Module Support: Supports AMD, CMD, CommonJS, and Standalone module formats.
    • Rendering Engines: Provides multiple rendering options including DOM, Canvas, Flash, and WebGL.
    • Physics & Animation: Supports Chipmunk physics engine and DragonBones for skeletal animation.
    • Performance: Optimized for various browsers, including low-end mobile browsers via DOM rendering and older IE versions via Flash rendering.
  2. Overview of Hilo HTML5 Game Framework

    dev

    Hilo is a cross-end HTML5 game development solution developed by Alibaba Group. It provides an Object-Oriented Programming (OOP) environment with a visual object architecture to help developers build games quickly.

    Key Features:

    • Multiple Render Models: Supports CanvasRenderer, DOMRenderer, and WebGLRenderer.
    • Module Support: Independent module design supporting multiple styles (CMD, AMD, CommonJS, KMD).
    • Browser Compatibility: Compatible with multiple desktop and mobile browsers; includes a Flash Shim to support IE.
    • Extensions: Supports Chipmunk for physics and DragonBones for skeleton animation.
  3. Compile and build Hilo source

    dev

    Hilo uses gulp for its build process. To build the framework or its components, ensure you have the dependencies installed and use the following commands:

    • Install dependencies: npm install
    • Build source: gulp
    • Build extensions: gulp extensions
    • Build API documentation: gulp doc
    • Run tests: gulp test

    Built modules can be found in the build folder in various formats: CMD, AMD, CommonJS, and KMD.

    npm install
    gulp
    gulp extensions
    gulp doc
    gulp test
  4. Create a new game project with Hilo Generator

    dev

    You can use a Yeoman generator to scaffold a new Hilo game project quickly. First, install yo and generator-hilo globally, then run the generator.

    npm install -g yo
    npm install -g generator-hilo
    yo hilo
  5. Explore Hilo API Documentation and Samples

    dev

    Detailed information regarding the Hilo API and practical usage examples can be found at the following locations:

    • Full API Documentation: docs/api-en/index.html
    • API Samples:
      • Visual Objects (View): Bitmap, Sprite, Graphics, DOM element, Button, Background, Canvas Text.
      • Core Features: Load queue, Web sound, Mouse Event, Drag.
      • Extensions: Camera, Camera3d, Skeleton Animation (Dragonbones), Particle System, Physics.
  6. Use jsrun.sh to simplify JsDoc Toolkit execution

    dev

    The jsrun.sh shell script simplifies running JsDoc Toolkit, especially within build environments like Ant. It handles long paths and environment variables to reduce command-line complexity.

    Usage: ./jsrun.sh <run.js arguments>

    Environment Variables:

    • JSDOCDIR: If set, adds -Djsdoc.dir=$JSDOCDIR to the command.
    • JSDOCTEMPLATEDIR: If set, adds -Djsdoc.template.dir=$JSDOCTEMPLATEDIR to the command.

    If these variables are not set, the script assumes jsrun.jar and the app/ directory are in the current working directory.

    Example: If JSDOCDIR is set to /some/path/to/my/jsdoc, running ./jsrun.sh ./src/ will execute: java -Djsdoc.dir=/some/path/to/my/jsdoc -jar /some/path/to/my/jsdoc/jsrun.jar /some/path/to/my/jsdoc/app/run.js ./src/

  7. Use DragonBones with Hilo

    dev
    To use DragonBones in a Hilo project, you must create a dragonBones.HiloFactory, load your texture and skeleton data, build an armature, and then add that armature to both the dragonBones.WorldClock and a Hilo Stage. You must also ensure a Hilo.Ticker is running to drive the dragonBones clock and the stage.
  8. Run JsDoc Toolkit via Command Line

    dev

    JsDoc Toolkit is an automatic documentation generator that converts JavaDoc-like comments in JavaScript source code into HTML or XML. It requires a Java runtime environment to execute.

    To run the tool, navigate to the jsdoc-toolkit directory and use the java -jar jsrun.jar command pointing to the app/run.js entry point.

    Common Command Patterns:

    • Windows: java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js

    • Mac OS X / Linux: java -jar jsrun.jar app/run.js -a -t=templates/jsdoc mycode.js

    Key Options:

    • -a: (Implicitly used in examples) Likely enables specific processing modes.
    • -t=<template_path>: Specifies the template directory to use for output generation.
    • -d=<directory>: Specifies the output directory. If not provided, documentation is saved to a directory named out in the current directory.
    • --help: Displays usage notes and help information.
  9. Create a Hilo game project using Yeoman

    dev

    You can quickly scaffold a new Hilo game project using the generator-hilo Yeoman generator. This will create a pre-configured initial project structure for your game.

    npm install -g yo
    npm install -g generator-hilo
    yo hilo
  10. Add physics capabilities to a class using PhysicsViewMixin

    dev

    Use Class.mix(target, PhysicsViewMixin) to inject physics functionality into a target class. This adds a body property (of type cpBody) and several movement methods.

    Available Methods:

    • applyImpulse(impulse, pos): Apply an impulse {x, y} at a relative position {x, y} from the center of mass.
    • applyForce(force, pos): Apply a force {x, y} at a relative position {x, y} from the center of mass.
    • setPosition(x, y): Set the physical position.
    • setRotation(rotation): Set the rotation in degrees.