Class: Pool

collie. Pool

new collie.Pool(nSize, htOption, fClass)

A simple object Pool

Name Type Default Description
nSize Number

Pool size (number of objects in the Pool)

htOption Object

Default options to create displayObjects

fClass Function collie.DisplayObject optional

The Pool contains objects created by this class

Examples

var pool = new collie.Pool(10, { backgroundImage : "test" });

// Use 5 objects var a = pool.get().addTo(layer); var b = pool.get().addTo(layer); var c = pool.get().addTo(layer); var d = pool.get().addTo(layer); var e = pool.get().addTo(layer);

// Release 5 objects pool.release(a); pool.release(b); pool.release(c); pool.release(d); pool.release(e);

// Change Pool size after initializing a Pool class. pool.changeSize(20);

You can also make the Pool contain other classes.

var circlePool = new collie.Pool(10, {
 radius : 10
}, collie.Circle);

Requires

  • module:collie.addon.js

Methods

changeOption(htOption)

Change the default options to create displayObjects

Name Type Description
htOption Object

changeSize(nSize)

Change the size of the Pool.

Name Type Description
nSize Number

Get an object from the Pool

getSize(){Number}

release(oTarget)

Release an object from the Pool

Name Type Description
oTarget collie.DisplayObject
comments powered by Disqus