在开始之前假定你已经知道flixel。 我曾在前一段时间的日志flixel for absolute beginners 和 flixel for absolute beginners – part 2里提到过flixel的基本知识。 一系列的教程之旅开始了,但在这之前我再重申明下创建这个flixel游戏的基础用的是Flash Builder 4. 你是否认为我把“Flex”混淆成了“Flash”?Flex 3以后的新版本已经更名为Flash Builder 4,你可以查看新功能同样也可以在Adobe官网上下载Flash Builder 460天试用版。 基本上这篇教程是TUTORIAL: Hello, World! [Flex Builder 3.0, OSX]的移值,现在使用Flash Builder 4。许多新的特色将在不同的步骤中展现。
1、开始创建一个新的Actionscript项目
 2、命名为HelloWorld
 3、接着选择项目的“properties”
 4、在Actionscript Build Path选项中选择Source path接着点击Add Folder。
 5、浏览并选择flixel包所在目录,若没有请下载。
 6、你会看到如下窗口所示
 7、接着创建一个新的Actionscript类。
 8、命名为PlayState,并让它从FlxState类继承。
 9、现在准备已完成,你应该有两个以.as后缀命名的文件:HelloWorld.as 和 PlayState.as 你的Package explorer看上去如下所示:
 下面是HelloWorld.as的代码。
package { import org.flixel.*; //Allows you to refer to flixel objects in your code [SWF(width="520", height="240", backgroundColor="#000000")] //Set the size and color of the Flash file
public class HelloWorld extends FlxGame { public function HelloWorld() { super(260,120,PlayState,2); //Create a new FlxGame object at 320x240 with 2x pixels, then load PlayState } } }
下面是PlayState.as的内容
package { import org.flixel.*; public class PlayState extends FlxState { override public function create():void { add(new FlxText(0,0,100,"Hello, World!")); //adds a 100px wide text field at position 0,0 (upper left) } } }
|