Jump to content

Compiling TypeScript + Pixi to native Android, Flash, Windows ...etc


Ezelia
 Share

Recommended Posts

as many of you here I use TypeScript + VS2012 for HTML5 games programming.
 
and some weeks ago I discovered haxe+NME and how they can easily target multiple platforms.
 
 
TypeScript output clean JS code and is perfectly integrated to VS2012 environment, but it can only target HTML5 games.
 
Haxe/NME produce native Android, iOS, Flash, Windows and HTML5  but the JS output is not clean, and I find TypeScript syntax better than haxe also (this is my personal point of view :) )
 
 
so I combined the best of two worlds to make it possible to cross compile a typescript code using pixi renderer to all haxe targets : Win, Flash, Android ...etc :)
 
 
here is a video demonstrating a proof of concept
 


 
 
most of pixi API is not implemented yet, and the conversion from TS to haxe is not complete (see http://www.html5gamedevs.com/topic/563-typescript-to-haxe-converter-a-first-step-for-ts-native-androidios/ )
but the idea is here .

what do you think  ?  :)
Link to comment
Share on other sites

what do you think  ?  :)

This is... interesting. As fact, very interesting.

I find concept of having game target primarily JavaScript and have other targets as fallback/extras (since JS-HTML5 on phones is normally the largest problem) rather appealing. Not exactly fan of TypeScript (working with Haxe as-is), but this certainly would have some uses.

Looking at TS->Haxe convertor topic again, how exactly are you converting for-loops to while-loops? The closest approach to converting loop,

for (s; c; p) { a; }
that I've seen was around
s;while (c) {    a;    p;}
but that would "mysteriously implode" once you adding in a "continue;" statement (infinite loop because of being unable to reach post-iteration code).
Link to comment
Share on other sites

Thank you for your comments :)

Actually I made this because the HTML5 performance of Haxe is horrible compared to what we can do with canvas/WebGL or eaven better use a renderer like pixijs ...
 

 

and about the for loop conversion I use the unfold syntax you wrote above, it covers almost all cases but as you said it can fail in some conditions ... btw for loop syntax is one of things I can't undestand from Haxe team :/  it's one of the most powerful syntax in programing languages why do they refuse to implement it :( ?    this is one of things that pushed me to not adopt haxe (I still use it to create native games for Android)

Link to comment
Share on other sites

Actually I made this because the HTML5 performance of Haxe is horrible compared to what we can do with canvas/WebGL or eaven better use a renderer like pixijs ...

Did you mean Haxe+NME HTML5 performance is horrible? Because Haxe itself produces fairly clean JavaScript code, and you may utilize any HTML5 functionality if you create a "just Haxe-JS" project or use a minor hack to replace NME library with your own code for HTML5 target in a NME project. I can provide more information on this, if it's of interest.

 

and about the for loop conversion I use the unfold syntax you wrote above, it covers almost all cases but as you said it can fail in some conditions ... btw for loop syntax is one of things I can't undestand from Haxe team :/  it's one of the most powerful syntax in programing languages why do they refuse to implement it :( ?    this is one of things that pushed me to not adopt haxe (I still use it to create native games for Android)

To be honest, I'm not completely sure why for-loop has a single "iterator" style syntax declaration possible. All targets seem to support either classic for-loops or "jump" keyword, which should've ensured that these are possible. Could ask on forums about this, actually.
Link to comment
Share on other sites

Did you mean Haxe+NME HTML5 performance is horrible? Because Haxe itself produces fairly clean JavaScript code, and you may utilize any HTML5 functionality if you create a "just Haxe-JS" project or use a minor hack to replace NME library with your own code for HTML5 target in a NME project. I can provide more information on this, if it's of interest.

 

sure ! I'd like to replace the default NME HTML5 output ... it seems to be using a library called jash witch is a AS3 "bad" implementation in JS/HTML5 .

I consider it bad because the HTML5 output of NME create a new canvas for each sprite witch slow down the game.

I looked into NME code and I think I understand how it works but from my understanding, if I want to replace the HTML5 output I'll have to reaplement the whole NME API (AS3 API in fact)

btw, I see other haxe libraries witch seem to produce better HTML5 (https://github.com/aduros/flambe for example)

Link to comment
Share on other sites

sure ! I'd like to replace the default NME HTML5 output ... it seems to be using a library called jash witch is a AS3 "bad" implementation in JS/HTML5 .

I consider it bad because the HTML5 output of NME create a new canvas for each sprite witch slow down the game.

I looked into NME code and I think I understand how it works but from my understanding, if I want to replace the HTML5 output I'll have to reaplement the whole NME API (AS3 API in fact)

This is a bit of delayed reply, but I've dedicated a blog post to process of replacing NME API with your own for JS/HTML5 target.

And no, you do not necessarily have to reimplement the whole API for most of games - essentially canvas/buffer based games only need analogues of BitmapData, Shape, Sound, Event*, and a couple of other classes. From my experience, a FlashPunk/HaxePunk - like framework can be fit into as few as 10..15 classes, including helper classes like keyboard/mouse constants and collision shape implementations.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...