Ejemplo n.º 1
0
        // PA2 Factory method, create node and add to the list
        public GameSprite AddGameSprite(GameObject.Category category, GameSprite.Name name, float ag, float sx, float sy, float x, float y, Image img
                                        , float posx, float posy, float w, float h)
        {
            // pull one reserved node
            GameSprite ret = (GameSprite)this.PullFromReserved();

            // Modify the field
            ret.name   = name;
            ret.pImage = img;

            // Add first image to queue
            ret.addImage(img);

            ret.poRect             = new Azul.Rect(posx, posy, w, h);
            ret.poAzulSprite       = new Azul.Sprite(img.pAzulTexture, img.poRect, ret.poRect);
            ret.poAzulSprite.angle = ag;
            ret.poAzulSprite.sx    = sx;
            ret.poAzulSprite.sy    = sy;
            ret.poAzulSprite.x     = x;
            ret.poAzulSprite.y     = y;

            // for projectile sprite, add flyproxy
            if (category == GameObject.Category.Missile || category == GameObject.Category.Bomb)
            {
                ret.pProxy = new FlyProxy(category, ret);
            }
            else if (category == GameObject.Category.UFO)
            {
                ret.pProxy = new UFOProxy(ret);
            }
            else
            {
                ret.pProxy = new MoveProxy(ret);
            }

            // Add to the active list
            this.Add(ret);

            // Create and Add GameObject to GameObjectManager
            GameObjectManager.getInstance().Add(category, ret);

            return(ret);
        }