PageRenderTime 62ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

Markdown | 101 lines | 55 code | 46 blank | 0 comment | 0 complexity | 473b52310d60ca56486653bb858fcff0 MD5 | raw file
  1. # Project Files
  2. # Create New Project
  3. ## Using the "create" Command
  4. OpenFL includes a new project template you can use to generate a project quickly. Open a command-prompt or terminal, and run the following command, using the name you want for your project (such as "JetGame" or "Platformer") instead of "MyProject":
  5. openfl create project MyProject
  6. This will create a new directory with the same name as the project by default. If you want to use a different output directory, you can add an additional argument:
  7. openfl create project MyProject ~/Projects/MyProject
  8. ## Manually
  9. You can also create a project by hand, you will need a project file and an entry class to get started.
  10. There are two different forms of project files, *.xml or *.hxp, so you can decide which type of project file to use.
  11. An XML project file will generally remain compatible with the command-line tools, regardless of the version. However, a Haxe project file can include robust logic, and can call other process as part of the build process... even generate assets dynamically. It is up to you to decide what best matches your taste.
  12. ### Project XML
  13. You can call an XML project file "project.lime" or "project.xml", or technically any file name that you prefer, although the command-line tools search for *.lime then *.xml files when running commands that do not specify the project file name.
  14. Here is an example of a project XML file:
  15. <?xml version="1.0" encoding="utf-8"?>
  16. <project>
  17. <meta title="My Project" package="com.mycompany.myproject" version="1.0.0" company="My Company" />
  18. <app main="Main" path="Export" file="MyProject" />
  19. <source path="Source" />
  20. <haxelib name="openfl" />
  21. <assets path="Assets" rename="assets" exclude="openfl.svg" />
  22. <icon path="Assets/openfl.svg" />
  23. </project>
  24. This is just the start, you can read more about the full project XML format here: [Project XML Format](command-line_tools/project_files/
  25. ### Haxe Project
  26. For a Haxe-based project file, use the name of your project file class, with an *.hxp extension, for example, a class called "Project" may have a file called "project.hxp".
  27. Here is a sample Haxe project file:
  28. ```Haxe
  29. import project.*;
  30. class Project extends HXProject {
  31. public function new () {
  32. super ();
  33. meta = { title: "My Project", packageName: "com.mycompany.myproject", version: "1.0.0", company: "My Company" };
  34. app = { main: "Main", path: "Export", file: "MyProject" };
  35. sources.push ("Source");
  36. haxelibs.push (new Haxelib ("openfl"));
  37. includeAssets ("Assets", "assets", [ "*" ], [ "openfl.svg" ]);
  38. icons.push (new Icon ("Assets/openfl.svg"));
  39. }
  40. }
  41. ```
  42. ### Haxe Main Class
  43. You also need a Haxe entry class. This does not need to be very complicated.
  44. "Main" is the default, but you can use any name you want, so long as it is a valid Haxe class. If you specify a different name, you will need to set the `<app main="" />` or `app.main` value in your project file (depending on the type).
  45. You will also want to create it in the source path. For example, if the project includes "Source" as a source path, create "Source\Main.hx" for a class called "Main".
  46. Here is a sample entry class:
  47. ```Haxe
  48. package;
  49. import flash.display.Sprite;
  50. class Main extends Sprite {
  51. public function new () {
  52. super ();
  53. }
  54. }
  55. ```