Game Development Reference
In-Depth Information
The following code snippet shows the top direction case. Similar logic is
implemented for the other three directions.
public function _onPieceMatch(pid:int, dir:int):void {
var os:Sprite = null;
var dx:Number, dy:Number;
var tx:Number;
var ty:Number
var otx:Number
var oty:Number;
var diff:Point = null;
switch(dir) {
case DIR_TOP:
if ( !m_topMatch ) {
// mark top is matched
m_topMatch = true;
// we move the group
// that is smaller!
if ( m_group.getSize() >=
m_top.getGroup().getSize() ) {
// group of this piece is smaller
// than the other
// get the amount of pixels
// to move
diff = _getDiff(DIR_TOP);
m_top.getGroup().
// move it!
move(diff.x, diff.y, null);
}
else {
// The other group is smaller
// get the difference in
// position in pixels
diff = m_top._getDiff(DIR_BTM);
// move the other group
m_group.move(diff.x, diff.y, null);
}
// merge the groups &
// show the glow effect.
_showEffect(m_group.merge(m_group,
m_top.getGroup()));
}
break;
 
Search WWH ::




Custom Search