Archive for April 6th, 2014

Colisiones en OpenFL

Sunday, April 6th, 2014

Fallback or ‘alternate’ content goes here.
This content will only be visible if the SWF fails to load.

Para detectar si hay alguna colisión entre dos sprites se puede usar el método hitTestObject( DisplayObject ) de la siguiente manera:


if ( moving_left ) {
direction = DIRECTION_LEFT;
x = x - 1;
}

for (child in 1...parent.numChildren ) {
if ( Std.is(parent.getChildAt(child), Wall) ) {
if ( parent.getChildAt(child).hitTestObject (this) ) {
x = x + 1;
}
}
}