Titanium的2D游戏引擎模块-QuickTiGame2d

What is QuickTiGame2d?

QuickTiGame2d is a 2-dimensional game engine module for Titanium Mobile that provides quick and easy api to create casual 2d games on Titanium. QuickTiGame2d runs much faster on mobile devices because it is based on OpenGL ES: the industry-standard graphics library on embedded systems. Currently QuickTiGame2d supports both iOS and Android.

http://code.google.com/p/quicktigame2d/

An addictive Whac-A-Mol like game "Kawaz-tan tataki!" is included as example of QuickTiGame2d.
Titanium的2D游戏引擎模块-QuickTiGame2d

What does it look like?
// Obtain game module
var quicktigame2d = require('com.googlecode.quicktigame2d');

// Create view for your game.
var game = quicktigame2d.createGameView();

// Frame rate can be changed (fps can not be changed after the game is loaded)
game.fps = 30;

// Initialize your game scene
var scene = quicktigame2d.createScene();
game.pushScene(scene);

// Create your sprites and add them to the scene
var background = quicktigame2d.createSprite(
  {image:'background.png', width:640, height:960, x:0, y:0}
);

var sprite = quicktigame2d.createSprite({image:'ball.png'});

// Sprite sheet is supported
var tiles = quicktigame2d.createSpriteSheet(
  {image:'tiles.png', width:32, height:32}
);

// Add sprites to the scene
scene.add(background);
scene.add(sprite);
scene.add(tiles);

// Set sprite opacity to 50%
sprite.alpha = 0.5;

// Rotate sprite in 30 degree
sprite.rotate(30);

// Scale up the sprite by twice
sprite.scale(2);

// Z-order can be changed
background.z = 0;
sprite.z     = 1;

// Called when the game is loaded
game.addEventListener('onload', function(e) {
  Ti.API.info("your game is loaded");

  // Change position of your sprite
  sprite.x = game.screen.width  * 0.5;
  sprite.y = game.screen.height * 0.5;

  // Select first frame of sprite sheet
  tiles.frame = 0;

  // sprite sheet animation is also supported
  tiles.animate([0, 1, 2], 500);

  game.start();
}

// Called when the game enters frame
game.addEventListener('enterframe', function(e) {
  // Change position of your sprite
  sprite.x = sprite.x + 1;

  // Rotate your sprite
  sprite.rotate(sprite.angle + 6);
}

// Called when user taps screen
game.addEventListener('singletap', function(e) {
  // Note that Ti.UI.View returns non-retina coordinate even on retina devices,
  // so we have to take the scale into account to process touch event.
  var scale = game.screen.width / game.width;

  // Change position of your sprite
  sprite.x = e.x * scale;
  sprite.y = e.y * scale;

}


Performance Test
Titanium的2D游戏引擎模块-QuickTiGame2d

你可能感兴趣的:(Module,mobile,Titanium,game,appcelerator)