您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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/syserr.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. The recommended editor for creating Heaps applications is Visual Studio Code:download
  21. [Visual Studio Code](https://code.visualstudio.com/download)
  22. • Install Haxe Extension Pack:
  23. 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.
  24. ![](images/extensions.png)
  25. 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)
  26. #### Project creation & compilation:
  27. • Create a new directory helloHeaps
  28. • Create into it a file compile.hxml: this file will contain your Haxe compilation parameters and the libraries you are using.
  29. • Edit the compile.hxml (with VSCode or any other text editor) to set the following content:
  30. -lib heaps
  31. -js hello.js
  32. -main Main
  33. -debug
  34. • 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.
  35. • The -debug file allows generation of source maps in order to be able to debug your JS application.
  36. #### Open with VSCode:
  37. At this point, you can open the helloHeaps folder with VSCode by launching VSCode and navigating the main menu File > Open Folder
  38. ##### Example:
  39. Creating Hello World
  40. Create a new Main.hx in the directory and put the following content
  41. class Main extends hxd.App {
  42. override function init() {
  43. var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
  44. tf.text = "Hello World !";
  45. }
  46. static function main() {
  47. new Main();
  48. }
  49. }
  50. • This example creates a Heaps Text component, adds it to the 2D scene s2d and set its text.
  51. #### Compile Output:
  52. • 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
  53. Or ( you can use the command to get the Terminal:Ctrl+Shift+P)
  54. Select haxe : active configuration
  55. • You can now compile with Shift-Ctrl+B  (or by going Terminal > Run Build Task)
  56. • If everything works well, you should now have both hello.js and hello.js.map files created in your helloHeaps folder:
  57. ![](images/content.png)
  58. #### Run in Browser:
  59. 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:
  60. <!DOCTYPE>
  61. <html>
  62. <head>
  63. <meta charset="utf-8"/>
  64. <title>Hello Heaps</title>
  65. <style>
  66. body { margin:0;padding:0;background-color:black; }
  67. canvas#webgl { width:100%;height:100%; }
  68. </style>
  69. </head>
  70. <body>
  71. <canvas id="webgl"></canvas>
  72. <script type="text/javascript" src="hello.js"></script>
  73. </body>
  74. </html>
  75. In order to Run with Chrome, you need Chrome Debugger VSCode extension. Open again the Extension manager and search for Chrome to install it:
  76. ![](images/chrome.png)
  77. • 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.
  78. • If you click on Chrome label, it will open you a .vscode/launch.json similar to the tasks.json we had earlier for compiling.
  79. {
  80. "version": "0.2.0",
  81. "configurations": [
  82. {
  83. "type": "chrome",
  84. "request": "launch",
  85. "name": "Launch Chrome against localhost",
  86. "url": "http://localhost:8080",
  87. "webRoot": "${workspaceFolder}"
  88. }
  89. ]
  90. }
  91. You can either setup a web server on localhost:8080 to display the content, or either simply replace the url using the following value:
  92. "url": "file://${workspaceFolder}/index.html",
  93. Now Run again (through the menu or F5) and the browser should open and display Hello World
  94. ![](images/hello.png)
  95. #### Reference:https://heaps.io/