Archive for April, 2014

Collisions in OpenFL

Sunday, April 6th, 2014

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

To detect if there is a collision among two sprites, it is possible to use the method hitTestObject( DisplayObject ) this way:


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;
}
}
}

Lime.onKeyChange error in version 1.2.2 of openfl-native

Friday, April 4th, 2014

It seems that there is a bug in version 1.2.2 of openfl-native, This is causing a compilation error when compiling for the Android platform and using Linux as a host.
The error is displayed as following.


-compile:
[javac] Compiling 6 source files to /[PATH]/Export/android/bin/bin/classes
[javac] /[PATH]/Export/android/bin/src/org/haxe/lime/MainView.java:381: error: method onKeyChange in class Lime cannot be applied to given types;
[javac] me.HandleResult (Lime.onKeyChange (keyCode, true));
[javac] ^
[javac] required: int,int,boolean
[javac] found: int,boolean
[javac] reason: actual and formal argument lists differ in length
[javac] /[PATH]/Export/android/bin/src/org/haxe/lime/MainView.java:430: error: method onKeyChange in class Lime cannot be applied to given types;
[javac] me.HandleResult (Lime.onKeyChange (keyCode, false));
[javac] ^
[javac] required: int,int,boolean
[javac] found: int,boolean
[javac] reason: actual and formal argument lists differ in length
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 2 errors

The solution consists on upgrading openfl-native to version 1.3.0:

haxelib update openfl-native