khaguide
khaguide copied to clipboard
How to build for latest kha?
Hey... Thanks for the guide - super cool idea.... do you still use Kha?
I checked this out, and tried to git clone it recursively, and it didn't have a kha submodule, so it tried to use haxelib kha, which I have installed, and it fails with this:
~/gitrepos/khaguide/Empty
$ khamake Creating Kha project.
Exporting asset 1 of 24 (arial.ttf).
Exporting asset 2 of 24 (bomb1.wav).
Exporting asset 3 of 24 (bomb2.wav).
Exporting asset 4 of 24 (bomb3.wav).
Exporting asset 5 of 24 (bomb4.wav).
Exporting asset 6 of 24 (engine_blimp.wav).
Exporting asset 7 of 24 (engine_plane.wav).
Exporting asset 8 of 24 (explode1.wav).
Exporting asset 9 of 24 (explode10.wav).
Exporting asset 10 of 24 (explode11.wav).
Exporting asset 11 of 24 (explode12.wav).
Exporting asset 12 of 24 (explode2.wav).
Exporting asset 13 of 24 (explode3.wav).
Exporting asset 14 of 24 (explode4.wav).
Exporting asset 15 of 24 (explode5.wav).
Exporting asset 16 of 24 (explode6.wav).
Exporting asset 17 of 24 (explode7.wav).
Exporting asset 18 of 24 (explode8.wav).
Exporting asset 19 of 24 (explode9.wav).
Exporting asset 20 of 24 (hit.wav).
Exporting asset 21 of 24 (miss.wav).
Exporting asset 22 of 24 (music.wav).
Exporting asset 23 of 24 (spritedata.json).
Exporting asset 24 of 24 (sprites.png).
Assets done.
Haxe stderr: ../Sources/Main.hx:9: lines 9-13 : { width : Int, title : String, height : Int } should be String
../Sources/Main.hx:9: lines 9-13 : For function argument 'title'
../Sources/Empty.hx:220: characters 3-21 : Class<kha.System> has no field windowWidth
../Sources/Empty.hx:221: characters 3-22 : Class<kha.System> has no field windowHeight
I then tried to add the submodule, but that failed:
$ git submodule add https://github.com/KTXSoftware/Kha 'Empty/Kha' already exists in the index
How can I build this project using the latest Kha? Thanks!
It seems Kha wasn't added properly. I'm not good to deal with problems in submodules, so I will show a different way. First download this repo and unpack in your system. Delete these files: .gitmodules \Empty.gitmodules \Empty\Kha (delete the folder) In the root folder of the repo call: git init Then enter in \Empty and call: git submodule add https://github.com/KTXSoftware/Kha git submodule update --init --recursive (wait some minutes..) Change the file khafile.js in \Empty, replace: return project; to: resolve(project);
now in Empty you can call node Kha/make html5 to build a project for html5. And if you don't want to wait for Kha to be downloaded for every project, you can use one clone of Kha for all the projects, see "Using Kha from one place" here: https://github.com/KTXSoftware/Kha/wiki/Getting-Started But for important projects is recommended to have Kha inside your project, because you can lock a version this way and avoid breaking changes.
Thanks! That totally worked... I had to do one more git step in there, which was git rm --cached Empty/Kha
after I removed the files, otherwise it'd complain with "already exists in the index"....
So my steps were:
git clone https://github.com/triplefox/khaguide.git
cd khaguide
rm .gitmodules
rm Empty/.gitmodules
rm -fr Empty/Kha
git init
git rm --cached Empty/Kha
git submodule add https://github.com/KTXSoftware/Kha Empty/Kha
git submodule update --init --recursive
and then it worked. It built the build/html5/index.html file, which I tried to just view in Chrome, but it wouldn't work, but it did work when I served it from a webserver, which can be easily done by running the following from a command line, from the Empty/build/html5/
folder:
python -m SimpleHTTPServer 8080
then opening http://localhost:8080
in your browser. Thanks!
That's because you cloned the project, using the download button in the front page the files would come without the git references (I should had explained better).
Html5 games always need to be opened using a webserver, because the files are referenced like in a server. If you are in windows FlashDevelop has a internal webserver, otherwise you can use node Kha/make --server
.
And haxe has a server too, you don't need python, just use this in build/html5
nekotools server -p 2000
ahh... cool... thanks so much.... that's definitely tons nicer!
Made an update for latest Kha here: https://github.com/RblSb/khaguide I apologize to @triplefox for refusing the docbook. If you are still alive and you are satisfied with the new structure, I will post PR.