Hi. I am having a very weird problem here.
I made two classes to display xp in the game, Xp_Bar and Xp_Bar_XP…
Xp_Bar works just fnie, but Xp_Bar_XP doesn’t! I can’t figure out why.
Here is the gameworld.
package
{
import assets.xp_bar.XpBar;
import assets.xp_bar.XpBar_XP;
import flash.geom.Point;
import flash.text.TextField;
import net.flashpunk.FP;
import net.flashpunk.graphics.Text;
import net.flashpunk.World;
import Talents.Talent_Tree;
import assets.hp_globe.HpGlobe
import assets.hp_globe.HpGlobe_HP;
public class GameWorld extends World
{
[Embed(source = "levels/level1.oel", mimeType = "application/octet-stream")] private static const LEVEL_1:Class;
private var stats:HeroStats = new HeroStats();
private var xpbar:XpBar = new XpBar(470, 980);
private var xpbarxp:XpBar_XP = new XpBar_XP(470, 980);
public function GameWorld()
{
}
override public function begin():void
{
var level:Level = Level(add(new Level(LEVEL_1)));
add(xpbar);
add(xpbarxp);
super.begin();
}
//End
}
}
And here are the two classes.
Working one:
package assets.xp_bar
{
import net.flashpunk.FP;
import net.flashpunk.Entity;
import net.flashpunk.Graphic;
import flash.geom.Rectangle;
import net.flashpunk.graphics.Image;
public class XpBar extends Entity
{
[Embed(source="../XpBar.png")] private const XP:Class;
private var graphicfx:Image;
public function XpBar(xPosition:int, yPosition:int)
{
x = xPosition;
y = yPosition;
layer = 1;
graphicfx = new Image(XP);
graphic = graphicfx;
}
override public function update():void
{
x = 460 + FP.world.camera.x;
}
}
}
not working one:
package assets.xp_bar
{
import net.flashpunk.FP;
import net.flashpunk.Entity;
import net.flashpunk.Graphic;
import flash.geom.Rectangle;
import net.flashpunk.graphics.Image;
public class XpBar_XP extends Entity
{
[Embed(source="../XpBar_XP.png")]private const XPXP:Class;
private var graphicfx:Image;
public function XpBar_XP(xPosition:int, yPosition:int)
{
x = xPosition;
y = yPosition;
layer = 1;
graphicfx = new Image (XPXP);
graphic = graphicfx;
}
override public function update():void
{
var maxXp:int = HeroStats.xpReq;
var currentXp:int = HeroStats.xp;
var percentXp:Number = currentXp / maxXp;
x = 460 + FP.world.camera.x;
graphicfx.scaleX = percentXp;
}
}
}
And here is the herostats class, just in case.
package
{
import net.flashpunk.Entity;
public class HeroStats extends Entity
{
public static var hp:int = 100;
public static var strength:Number = 1;
public static var armor:Number = 3;
public static var magicResist:Number = 50;
public static var agility:Number = 1;
public static var jumpPower:Number = 22;
public static var luck:Number = 1;
public static var speed:Number = 1;
public static var xp:int = 0;
public static var xpLevel:int = 1;
public static var talentPoints:int = 0;
public static var xpReq:int;
public function HeroStats()
{
}
override public function update():void
{
//Conversion
//Armor
armor = 1 - (armor / 100)
//Magic resist
magicResist = 1 - (magicResist / 100)
xpReq = xpLevel * 10;
if (xp >= xpReq)
{
xpLevel ++; xp = 0;
talentPoints ++;
}
}
}
}
I get this error when I try to run the game:
obj\Dwarflets635312771690575686 (529493 bytes) C:\Dwarflets\src\assets\xp_bar\XpBar.as(-1): col: -1 Warning: Class ‘assets.xp_bar:XpBar_XP’ does not extend the ‘DefineBits’ asset base class ‘flash.display.Bitmap or flash.display.BitmapData’. package assets.xp_bar ^ Build halted with errors (fcsh). (fcsh) Done(1)
What is going on here? I’m seriously confused