class Car{ public static var noOfWheels:Int = 4;
public function new() { }
public static function getNoOfWheels():Int { return Car.noOfWheels; }}
trace (myCar.noOfWheels);Cannot access static field noOfWheels from a class instance
trace (myCar.getNoOfWheels());
Cannot access static field getNoOfWheels from a class instance
trace (Type.getClass(myCar).noOfWheels);Class<Car> has no field noOfWheels
--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/7a16ae0b-9c75-46b0-b24e-1f409a3e288f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
for (i in 0...5){ myCar = new Car(i); cars.push(myCar);}
class Car{ public static var noOfWheels:Int;
public function new(num:Int) { noOfWheels = num; }
}
--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/f94f9b7c-7918-4e0a-9ea6-dc80940907bf%40googlegroups.com.
I'm programming an RPG where every time the player enters a new room, a number of NPC's are loaded in the new map (if there's any), each one with their own array of dialogues, for example:
class Char extends FlxSprite{ public static var dialogue:Array<String> = [];
public function new(dialogue:Array<String>) { this.dialogue = dialogue;
//more code...
}
}
var chat:Array<Array<String>> = [ ["line 00", "line 01"], ["line 02", "line 03"], ["line 04", "line 05", "line 06"] ]; for (i in 0...3) { char = new Char(chat[i]); chars.push(char); }
trace(char[0].dialogue);
About the `Car`, there are 2 ways:
1. You should make `noOfWheels` non-static
2. You ought to make 2 class of car like `FourWheel' and `FiveWheel` with static `noOfWheels`