- 积分
- 136119
- 注册时间
- 2014-12-27
- 最后登录
- 2024-3-28
- 在线时间
- 602 小时
- 威望
- 562
- 贡献
- 29
- 金币
- 52623
- 钢镚
- 1422
- 交易凭证
- 1
- 分享
- 0
- 精华
- 33
- 帖子
- 2094
- 主题
- 1742
TA的每日心情 | 擦汗 2018-4-10 15:18 |
---|
签到天数: 447 天 [LV.9]以坛为家II
超级版主
- 威望
- 562
- 贡献
- 29
- 金币
- 52623
- 钢镚
- 1422
|
楼主 |
发表于 2015-1-19 16:37:47
|
显示全部楼层
使用hxcc
本例演示如何使用hxcc呈现一个字符串,效果如下:
源码如下:
- package ;
- import com.plter.hxcc.app.HxccApplication;
- import com.plter.hxcc.display.HxccLabelTTF;
- import com.plter.hxcc.display.HxccLayer;
- import com.plter.hxcc.app.HxccApplicationEvent;
- import com.plter.hxcc.app.HxccConfig;
- class Main extends HxccApplication{
- public function new() {
- var config:HxccConfig = new HxccConfig();
- //指定Cocos2d-html5库的位置
- config.engineDir = "../../hxcc/lib/cocos2d/";
- //将配置数据传给父类构造方法
- super(config);
- //侦听应用程序加载并创建完成的事件
- creationComplete.addListener(creationCompleteHandler);
- }
- private function creationCompleteHandler(e:HxccApplicationEvent):Bool{
- //创建一个层
- var layer:HxccLayer = new HxccLayer();
- //获取场景对象并将层添加到场景中
- getScene().addChild(layer);
- //创建一个LabelTTF组件,配置其属性,并将其添加到层中
- var l:HxccLabelTTF = new HxccLabelTTF("Hello Hxcc");
- l.setPosition(200,200);
- l.setFontSize(50);
- layer.addChild(l);
- return true;
- }
- public static function main():Void{
- new Main();
- }
- }
复制代码 该库依赖jQuery库,所以在使用该库时需要在HTML中先引入jQuery库,则HTML代码如下所示:
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <script type="text/javascript" src="../../hxcc/lib/jquery-2.0.2.min.js"></script>
- </head>
- <body>
- <canvas width="800" height="500" id="gameCanvas"></canvas>
- <script type="text/javascript" src="app.js"></script>
- </body>
- </html>
复制代码 其中app.js是haxe代码编译生成的
本文来自:http://plter.lofter.com/post/c6445_78c2a4
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|