Quantcast
Viewing latest article 1
Browse Latest Browse All 16

Extended class functions

Lets say i had a simple class that extends another class: class Item { private var name : String = "itemName"; private var price : int = 21; private var weight: int = 1; function _get(what:String){ if(what=="price")return price; if(what=="weight")return weight; } } class Weapon extends Item { private var damage : int = 10; private var speed : int = 5; function _get(what:String){ if(what=="damage")return damage; if(what=="speed")return speed; } } function Start () { var wep = new Weapon(); print(wep._get("damage"));//prints 10 print(wep._get("price")); //prints 0 ??? } The problem is - i can't seem to get the base class variables - price or weight in this example. Maybe there is a special way of extending a function? Any help would be appreciated.

Viewing latest article 1
Browse Latest Browse All 16

Trending Articles