Game Development Reference
In-Depth Information
Let's slide back to the start of the chapter where we said that the Stage class
holds the reference to all initialized textures and each StageObject holds the
textureIndex , the index to the initialized texture. Now, if we change the value
of the textureIndex property in the update call, it will render each time with a
different texture, giving an illusion of the animation.
Let's look at textures, shown in the following screenshot, which we have created to
simulate an explosion:
We will apply these textures to an explosion object ( explosion.json from the
model\weapons folder of the code bundle).
So, first let's understand our explosion.js file from the primitive/game folder of
the code bundle.
The Explosion class has a new textureIndices[] variable in the place of the
positions array. This array holds the indices of textures defined in the primary
Stage class.
Explosion= inherit(StageObject, function (){
superc(this);
this.textureIndices=[];
this.counter=0;
this.visible=false;
});
 
Search WWH ::




Custom Search