lundi 17 avril 2017

How do I assign values to a class using its parameters? - Basic

so I'm using flash punk to work on a game and i've created a base class that contains the characters stats based on the type of character the player chooses. this is what that class looks like so far.

public class Stats extends Entity
{
        public var ATK:Number;
        public var ARM:Number;
        public var SPD:Number;
        public var WIS:Number;
        public var CRG:Number;
        public var STM:Number;

    public function Stats(ATK:Number=0, ARM:Number=0, SPD:Number=0, WIS:Number=0, CRG:Number=0, STM:Number=0)
    {

    }
    override public function update():void 
    {
        super.update();

    }
}

and in another class when a button is clicked i would like it to make a new stats class with the parameters (2, 6, 2, 2, 4, 4) so i do

public var SkelStats:Stats = new Stats(2, 6, 2, 2, 4, 4);

and then assign that object (SkelStats) to the players boss type varriable. I do this

public static var BossType:Stats;

and then in the button class under the click function I add

Player.BossType = SkelStats; trace(Player.BossType.ATK)

and the trace always puts out 0 unless i change the varriable (ATK) in the stats class itself. Why doesn't it change when I enter it in the parameters for the instance of the class?(SkelStats)

Sorry if this is all too confusing, I can answer any questions about my code if anything is unclear. I'm just not sure what I'm doing wrong here.

Aucun commentaire:

Enregistrer un commentaire