Game Development Reference
In-Depth Information
Figure 14-18.
The level complete screen with magic shop
If a button is enabled and is clicked, the
purchaseItem
is called. This event handler is given the cost of the item so
it can be subtracted from the player's coins. This is accomplished by using the
data
parameter in the
on
method.
btn.on('click', this.purchaseItem, this, false, {cost:cost});