4 ms·
So far I only reimplemented those Canvas API functions needed for the game; the most important one being .drawImage(). What I mean by "reimplement", is providi
by phoboslab 16y ago
So far I only reimplemented those Canvas API functions needed for the game; the most important one being .drawImage().
What I mean by "reimplement", is providing a .drawImage function for JavaScript that works in the same way as it does in the browser, but uses OpenGL-ES behind the scenes. This reimplementation is done in native Objective C.
The changes I had to make to Impact (the "HTML5" engine) are concerned with the loading of images, scaling, input and getting a reference to the canvas element and its drawing context. But I guess I could provide a dummy "document" and "getElementById" function, so that you can just write some JavaScript using Canvas and run it in the browser and on the iPhone unchanged.
Note that this whole idea isn't exactly new:
http://www.youtube.com/watch?v=0UN2iYrZmEY http://www.youtube.com/watch?v=0UN2iYrZmEY