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

[size=large][b]What is QuickTiGame2d?[/b][/size]

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.

[url=http://code.google.com/p/quicktigame2d/]http://code.google.com/p/quicktigame2d/[/url]

An addictive Whac-A-Mol like game "Kawaz-tan tataki!" is included as example of QuickTiGame2d.
[img]http://dl.iteye.com/upload/attachment/0062/5822/76735cfc-c2cb-31c2-88c3-c53cf8b1230e.jpg[/img]

[size=large][b]What does it look like?[/b][/size]

// 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;

}


[size=large][b]Performance Test[/b][/size]
[img]http://dl.iteye.com/upload/attachment/0062/6739/49b4953d-3989-3fc0-aae4-e9d48e02dde0.jpg[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值