Canvas+ Features

Category with articles explaining the Canvas+ special features.

Canvas+ Quickstart guide

The Cocoon accelerated canvas (Canvas+ from now on) for 2D and WebGL is a highly optimized JavaScript Virtual Machine for iOS and Android that implements a subset of the HTML5 standard. Actually, this is one of the first things that has to be noticed: The Canvas+ environment is not a full browser, it’s a very […]

Store XMLHTTPRequest

Cocoon tries to be as HTML5 compliant as possible but sometimes, as we have full control over the JS environment, we see opportunities to add cool features that are not directly available in the standard APIs. In this case we have added a very simple extension function to Canvas+ XMLHttpRequest object to be able to […]

Canvas+ API

Canvas+ has some special API that are exclusive of this webview engine and that are not available in the other engines. Some of this features can also be accomplished with Cordova or a Cordova plugin and are just legacy. App Device Different methods to have acceso to the device information. Dialog Methods to access the dialog/prompt […]

Canvas+ internal webview

Canvas+ allows accessing a full DOM environment via Webview. Thus, there are two environments that live together: Canvas+ and WebView. Although both are two different JavaScript environments, Cocoon allows to render a transparent Webview on top of the Canvas+ OpenGL ES rendering context and it also provides a bidirectional communication channel between them. In this […]

Memory management tips

Memory is a critical resource in HTML5/JavaScript game development, especially on mobile devices. In a desktop environment you can load tons of textures but on some low-end mobile devices you can reach the maximum RAM limit quickly. Although JavaScript encourages automatic memory management by using a garbage collection mechanism, you shouldn’t ignore effective memory management […]

NPOT textures

Canvas+ uses POT (Power Of Two) textures by default in 2d contexts. This is very useful for performance improvements, especially on mobiles with old GPUs. But it can waste memory on games that don’t use packed or 2^n textures. In Canvas+ you can allow NPOT textures in Canvas2D contexts (they were already supported in WebGL). […]

Lazy loading

Another Canvas+ exclusive feature available on version 2.1 and higher we have added the “cocoonLazyLoad” boolean property to Image objects (we have also added a duplicate called “idtkLoadDisposed” for retro compatibility with Construct2). When the property is set to true, the image is not loaded until it’s used in a render operation. Engines that load […]

Max memory thresold

This new Canvas+ exclusive feature exposes the “setMaxMemory” utility method. When the max memory threshold is set, Cocoon checks the total amount of texture sizes (images and canvases). When the runtime memory size reaches the max memory threshold, Cocoon disposes of the least recently used textures until the memory fits the threshold. It disposes of […]

Texture reducer

Texture reducer is a Canvas+ exclusive feature. When your game targets all resolutions you need huge textures for iPad retina like devices and small textures for small mobile devices. A game developer has many ways to handle this: Create different asset packages, HD and normal. Good solution but bigger app size. Scale down HD resources. […]

Screencanvas

ScreenCanvas is a canvas+ specific high performance canvas. In canvas+ you can create 2 types of canvas: A standard canvas renders everything to an internal drawing buffer (render to texture). At the end of the frame the texture is drawn to the screen buffer. A screencanvas doesn’t create any internal drawing buffers. It renders directly […]