Game Development Reference
In-Depth Information
Removing a game state
For removing an existing game state, we need to handle the Remove button. The
handler is shown below:
private function removeGS(e:Event):void {
// Remove button was clicked
if ( m_selected != null ) {
PulseGame.getInstance().
getGameClient().
removeGameState(m_selected.m_gs);
}
}
Whenever a mouse up is detected on the game state sprite, we keep a track of the
current selected sprite.
The following is the setSelected method that keeps track of the current selection. It
also takes care of setting the filter on the sprite so that we can see the selected sprite
visually. When a new selection is made, we also need to remove the filters from the
previously selected filter.
private function setSelected(sel:GameStateSprite):void {
var filters:Array;
if ( m_selected != null ) {
// existing selection
filters = m_selected.filters;
filters.splice(0, 1);
m_selected.filters = filters;
}
m_selected = sel;
if ( m_selected != null ) {
// add the filter
filters = m_selected.filters;
filters.push(FilterFactory.
createFilter(FilterFactory.DROP_SHADOW_FILTER));
m_selected.filters = filters;
}
}
 
Search WWH ::




Custom Search