I’m trying to do create random enemies, so I’ve got classes, Enemy1, Enemy2, Enemy3, …
In Flash I would have generated the number part randomly and then create the new class by using getDefinitionByName(“Enemy”+(rnd)).
I thought you could do this in Haxe by using Type, but that doesn’t appear to be the case.
Is there a way I can do this?
This is the apparent equivalent, (but doesn’t work.)
var rnd:Int = Std.int(1+Math.random()*3);
var eType:String = "dropSeven.game.Enemy"+rnd;
var EnemyClass = Type.resolveClass(eType);
var p:Enemy = Type.createInstance(EnemyClass, null);