forked from theblackcascade/Invaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XMLParser.as
60 lines (56 loc) · 1.56 KB
/
XMLParser.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package
{
import flash.geom.Point;
public class XMLParser
{
private static var _instance:XMLParser = new XMLParser();
public static function get Instance():XMLParser//делаем синглетон
{
trace("getInstance");
return _instance;
}
public function XMLParser():void
{
trace("Constructor");
if(_instance)
throw new Error("Use Instance Field");
}
public function GameSetup(xml:XML):void //Настройка с помощью ConfigXML
{
Game.Instance.stage.frameRate = xml.FrameRate;
Game.Instance.stage.stageWidth = xml.Width;
Game.Instance.stage.stageHeight = xml.Height;
Game.Instance.stage.nativeWindow.title = xml.Title;
Game.Instance.stage.nativeWindow.width = xml.Width;
Game.Instance.stage.nativeWindow.height = xml.Height;
var p:Point = new Point(xml.Width,xml.Height);
Game.Instance.stage.nativeWindow.maxSize = p;
Game.Instance.stage.nativeWindow.minSize = p;
}
public function LevelSetup(xml:XML):void
{
for each(var o:XML in xml.set)
{
for each(var o1:XML in o.*)
{
var object:GameObject = new GameObject();
trace(o1.x);
object.x = o1.x;
trace(o.attribute("y"));
object.y = o.attribute("y");
object.startFollowing(o1.x,o.attribute("y"));
trace(o.attribute("type"));
object.type = o.attribute("type");
GameObjectPool.Instance.Objects.push(object);
}
}
}
public function GraphicsPoolSetup(xml:XML):void
{
for each(var o:XML in xml.image)
{
ResourceLoader.Instance.LoadBitmap(o.url);
}
}
}
}