I have no idea why I'm struggling with this, but here I go.
I'm trying to call a method from one class in another, but it somehow refuses to comply, spitting out the infamous call to a possibly undefined method.
I'm trying to summon the function theResult() from the PlayState. Calling the inside of theResult() works inside of the update function of HUD, so the content is not the problem...
I've hidden the code that's not related to the problem with //HIDDEN.
Anyone got a clue what's wrong?
package gamestate
{
import common.*;
import enemy.*;
import entity.*;
import hud.*;
import item.*;
import org.flixel.*;
import player.*;
import stage.*;
public class PlayState extends FlxState
{
private var hud:HUD;
public function PlayState()
{
}
override public function create():void
{
//HIDDEN
}
public function setLevel(_level:Class):void {
//HIDDEN
//HUD
add(hud = new HUD());
}
override public function update():void {
super.update();
//HIDDEN
if (Globals.level.grpEnemies.countDead() == Globals.level.grpEnemies.length && Globals.level.roomType == 1) {
FlxG.log("Switched room type: 2");
Globals.level.roomType = 2;
hud.theResult();
}
}
//HIDDEN
}
}
package hud
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.FlxBar;
import org.flixel.plugin.wingeraser.FlxTimerPlus;
import player.Player;
import player.OnHand;
import hud.SystemWindow;
public class HUD extends FlxGroup
{
private var frame:FlxSprite;
private var hp_bar:FlxBar;
private var sp_bar:FlxBar;
private var hp:FlxText;
private var money:FlxText;
public var timer_sec:FlxTimerPlus;
public var timer_min:Number;
private var stage_time:FlxText;
[Embed("../../assets/hud/equipment_empty.png")]
private static var equipment_slot:Class;
[Embed("../../assets/font/Fairfax.ttf", fontFamily="Fairfax", embedAsCFF="false")]
private static var fairfax:String;
private var equip:FlxSprite;
private var map_base:CircleMap;
private var cursor_player:PlayerCursor;
private var results:BattleResults;
public function HUD()
{
super();
//HIDDEN
results = new BattleResults();
add(results);
}
override public function update():void
{
//HIDDEN
}
//HIDDEN
public function theResult():void {
results.showResults();
}
}
}
Any help would be greatly appreciated!