Actionscript 在starling游戏框架as3中添加图像作为视图

Actionscript 在starling游戏框架as3中添加图像作为视图,actionscript,starling-framework,Actionscript,Starling Framework,我对as3中使用starling库的游戏非常无知,它的示例代码创建的游戏运行良好,但不能添加简单的png图像作为英雄/敌人:(我的代码如下 public class radixState extends StarlingState { [Embed(source = "giants.png")] private var giantsPic:Class; [Embed(source = "ring.png")] privat

我对as3中使用starling库的游戏非常无知,它的示例代码创建的游戏运行良好,但不能添加简单的png图像作为英雄/敌人:(我的代码如下

public class radixState extends StarlingState
    {
        [Embed(source = "giants.png")]
        private var giantsPic:Class;

        [Embed(source = "ring.png")]
        private var ringPic:Class;

        [Embed(source = "tigers.png")]
        private var tigersPic:Class;


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

            /*var imgBitmap:BitmapAsset = new giantsPic();
            var bitmapData:BitmapData = imgBitmap.bitmapData;*/
            var mygiants:Image = new Image(Texture.fromBitmapData(new giantsPic().bitmapData));
            mygiants.height=70;
            mygiants.width=70;

            var physics:Box2D = new Box2D("box2D");
            physics.visible = true;
            add(physics);

            var floor:Platform=new Platform("floor",{x:512, y:748, width:1024, height:40});
            floor.view=new Quad(1024,40,0x333333);
            add(floor);

            var p1:Platform=new Platform("p1",{x:871, y:151, width:300, height:40});
            p1.view=new Quad(300,40,0x333333);
            add(p1);

            var mp:MovingPlatform=new MovingPlatform("moving",{x:220, y:700, width:200, height:40, startX:220, startY:700, endX:500, endY:151});
            mp.view=new Quad(200,40,0x333333);
            add(mp);

            var hero:Hero=new Hero("hero",{x:50, y:50, width:70, height:70});
            hero.view=mygiants;
            add(hero);

            var enemy:Enemy=new Enemy("enemy",{x:900, y:700, width:70, height:70, leftBound:10, rightBound:1000});
            enemy.view=new tigersPic();
            add(enemy);

            var goal:Coin=new Coin("ring",{x:957, y:90, width:79, height:79});
            goal.onBeginContact.add(function(c:b2Contact):void{
                    trace("Goal Raeched");
            }); 
            goal.view=new ringPic();
            add(goal)


        }
    } 

有人能帮忙吗?我只想添加英雄/敌人的图像

您正在将CitrusObjects添加到StarlingState,而要显示某些内容,您必须将(addChild)DisplayObject添加到starling sprite