AIR移植ANDROID之STARLING开源项目:Whack

Starling简介以及中文站:http://www.starlinglib.com

在ADOBE AIR出到3.0之后,AIR跨平台的优势被越来越多的人发掘。

特别是拥有完美封装STAGE3D API的开源框架STARLING的出现。

让更多的人使用AIR进行跨平台开发特别是游戏开发成为可能。

这在三年前可是想都不敢想的事情。

试想一下  未来 使用AIR开发的游戏肯定鲜花洒满地。

这次找到的是一个开源AIR游戏项目:Whack

游戏本身使用starling框架。

我们要把他移植到ANDROID下 只需要修改Whack.as文件即可。非常的简单
1.新建AIR手机项目
2.复制除了配置文件之外的全部源代码到相应文件夹
3.修改入口文件
[cc lang=”java”]
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.StageDisplayState;
import net.hires.debug.Stats;

import starling.core.Starling;

[SWF(frameRate=”60″, backgroundColor=”#333333″)]
public class AirWhack extends Sprite
{
private var _starling:Starling;
private var _menus:Screens;

/**
* The main application
*/
public function AirWhack()
{
//ViewSource.addMenuItem(this, “srcview/index.html”);
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
stage.displayState = StageDisplayState.FULL_SCREEN;
addEventListener(Event.ADDED_TO_STAGE, init);

}
private function init(ev:Event):void{
_menus=new Screens(); // Screens is in a SWC (don’t worry about looking for the class files)
_menus.addEventListener(“newGame”, startGame);

var stats:Stats=new Stats();
_menus.width = stage.stageWidth;
_menus.height = stage.stageHeight;
stats.x = stage.stageWidth – 70;
trace(stage.stageWidth+”-“+stage.stageHeight);
addChild(_menus);
addChild(stats);
addChild(new NativeStageProxy());
}
/**
* The Screens object dispatches a “newGame” event that is used to start Starling
* @param e
*/
public function startGame(e:Event=null):void
{
//Starling.multitouchEnabled=true;
//Starling.handleLostContext = false;
_starling=new Starling(Game, stage);
//_starling.simulateMultitouch=false;
_starling.enableErrorChecking=false;
_starling.start();
}
}
}
[/cc]

完成后物理机效果如图:

疑问:
1.在PC上运行一直可以保持60FPS,移植到我的山寨机THL V6上只能保持25~30
这是否和使用了原生FLASH有关?
项目下载

《AIR移植ANDROID之STARLING开源项目:Whack》有4个想法

  1. sky :
    我这边点NEW GAME之后 灰屏没反应 不知道怎么回事…

    解决了 估计是AIR SDK的问题 打包的时候选择不打包AIR 然后自己从市场下个最新的AIR装上就OK了。。

发表评论

邮箱地址不会被公开。 必填项已用*标注