No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Getting-started.md 4.7KB

hace 5 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #Getting Started:
  2. ####Introduction:
  3. Heaps is an open source and multi-platform toolkit to create 2D and 3D games.
  4. ####Installation:
  5. • To use Heaps.io, you need to install Haxe 3.4+
  6. • Later, Download the Heaps,
  7. [install](https://www.microsoft.com/en-ph/download/details.aspx?id=48145&751be11f-ede8-5a0c-058c-2ee190a24fa6=True).
  8. For windows 8: (incase you are facing with error)
  9. • If you are using windows 8, download Windows installer/Windows Binaries
  10. Check in the heaps folder whether its running fine or not.
  11. • If you are getting this error,
  12. (/images/system error.png)
  13. • Then please follow this link and download ,in your heap directory, manually we are installing it
  14. (https://www.sts-tutorial.com/download/api-ms-win-crt-heap-l1-1-0).
  15. ####Setup:
  16. Run in the command prompt
  17. #####haxelib install heaps
  18. ####Editor - Installation & Setup :
  19. • The recommended editor for creating Heaps applications is Visual Studio Code:
  20. [Download](Visual Studio Code).
  21. #####Install Haxe Extension Pack:
  22. Click on the #####Extension panel (fourth icon on the left side bar of VSCode), search haxe and install Haxe Extension Pack that will contain everything you need for Haxe support.
  23. (/images/extensions.png)
  24. If your VSCode is up to date (after v1.31), you're good to go. Otherwise, restart VSCode once installation is complete (you can click the Reload label that should be showing)
  25. ####Project creation & compilation:
  26. • Create a new directory helloHeaps
  27. • Create into it a file compile.hxml: this file will contain your Haxe compilation parameters and the libraries you are using.
  28. • Edit the compile.hxml (with VSCode or any other text editor) to set the following content:
  29. -lib heaps
  30. -js hello.js
  31. -main Main
  32. -debug
  33. • This will tell the compiler that we are using the library Heaps, that we will compile to JavaScript hello.js output, and that our main class should be Main.hx file.
  34. • The -debug file allows generation of source maps in order to be able to debug your JS application.
  35. ####Open with VSCode:
  36. At this point, you can open the helloHeaps folder with VSCode by launching VSCode and navigating the main menu File > Open Folder
  37. #####Example:
  38. Creating Hello World
  39. Create a new Main.hx in the directory and put the following content
  40. class Main extends hxd.App {
  41. override function init() {
  42. var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
  43. tf.text = "Hello World !";
  44. }
  45. static function main() {
  46. new Main();
  47. }
  48. }
  49. • This example creates a Heaps Text component, adds it to the 2D scene s2d and set its text.
  50. ####Compile Output:
  51. • In order to compile, you need to create a Build task with VSCode, this can be done by going into the VSCode menu and select Terminal > Configure Default Build Task
  52. Or ( you can use the command to get the Terminal: #####Ctrl+Shift+P )
  53. Select haxe : active configuration
  54. • You can now compile with #####Shift-Ctrl+B  (or by going Terminal > Run Build Task)
  55. • If everything works well, you should now have both hello.js and hello.js.map files created in your helloHeaps folder:
  56. (/images/content.png)
  57. ####Run in Browser:
  58. In order to run our example, we need to embed it into a web page. Create a file named index.html with the following content:
  59. <!DOCTYPE>
  60. <html>
  61. <head>
  62. <meta charset="utf-8"/>
  63. <title>Hello Heaps</title>
  64. <style>
  65. body { margin:0;padding:0;background-color:black; }
  66. canvas#webgl { width:100%;height:100%; }
  67. </style>
  68. </head>
  69. <body>
  70. <canvas id="webgl"></canvas>
  71. <script type="text/javascript" src="hello.js"></script>
  72. </body>
  73. </html>
  74. In order to Run with Chrome, you need #####Chrome Debugger VSCode extension. Open again the Extension manager and search for Chrome to install it:
  75. (/images/chrome.png)
  76. • Once installed, press F5 or do Debug > Start Debugging. This should give you the choice to Debug with Chrome. If not, restart VSCode so the extension is activated.
  77. • If you click on Chrome label, it will open you a .vscode/launch.json similar to the tasks.json we had earlier for compiling.
  78. {
  79. "version": "0.2.0",
  80. "configurations": [
  81. {
  82. "type": "chrome",
  83. "request": "launch",
  84. "name": "Launch Chrome against localhost",
  85. "url": "http://localhost:8080",
  86. "webRoot": "${workspaceFolder}"
  87. }
  88. ]
  89. }
  90. You can either setup a web server on localhost:8080 to display the content, or either simply replace the url using the following value:
  91. "url": "file://${workspaceFolder}/index.html",
  92. Now Run again (through the menu or F5) and the browser should open and display Hello World
  93. (/images/hello.png)
  94. ####Reference:https://heaps.io/