Author Topic: Problem with FlxKong in 2.x  (Read 1044 times)

Liaf

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
  • yay!
    • View Profile
Problem with FlxKong in 2.x
« on: Wed, Mar 10, 2010 »
I'm currently using a way to use the Kongregate API by using flixels built in class FlxKong, but it doesn't work as intended. My code looks like the following and is the same Adam Atomic posted somewhen.

Code: [Select]
if(!FlxG.kong){
  var g:FlxKong = new FlxKong();
  g.init();
  FlxG.kong = g;
}
if(FlxG.kong){
  FlxG.kong.API.stats.submitArray( [ { name:"level", value:someValue } ] );
}

Unfortunately I'm getting a Null-Point Exception here in FlxKong at line 37 (That's the first line of the init() function)

I hope someone can help me.

Matoking

  • Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Problem with FlxKong in 2.x
« Reply #1 on: Thu, Mar 11, 2010 »
This is how you are supposed to initialize it (put into a update() loop)
Code: [Select]
if(!FlxG.kong) (FlxG.kong = parent.addChild(new FlxKong()) as FlxKong).init();

Liaf

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
  • yay!
    • View Profile
Re: Problem with FlxKong in 2.x
« Reply #2 on: Thu, Mar 11, 2010 »
Ah, thanks for your help. Unfortunately now I'm getting a null-pointer-exception at this line of code
Code: [Select]
if (FlxG.kong) {
   FlxG.kong.API.stats.submitArray ( [ {name:"Souls gathered", value:countCoins}] );
}