public void playSound(string Sound) { sound.loadEmbedded("putt/sfx/" + Sound, false); sound.play(); }
/// <summary> /// Creates a new sound object. /// </summary> /// <param name="soundEffect">The embedded sound resource you want to play. To stream, use the optional URL parameter instead.</param> /// <param name="volume">How loud to play it (0 to 1).</param> /// <param name="looped">Whether to loop this sound.</param> /// <param name="autoDestroy">Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this <code>FlxSound</code> instance.</param> /// <param name="autoPlay">Whether to play the sound.</param> /// <param name="url">Load a sound from an external web resource instead. Only used if EmbeddedSound = null.</param> /// <returns>A <code>FlxSound</code> object.</returns> public static FlxSound loadSound(SoundEffect soundEffect, float volume = 1.0f, bool looped = false, bool autoDestroy = false, bool autoPlay = false, string url = null) { if (!string.IsNullOrEmpty(url)) { throw new NotSupportedException(); } var sound = new FlxSound(); sound.loadEmbedded(soundEffect, looped, autoDestroy); sound.Volume = volume; if (autoPlay) { sound.play(); } return sound; }
override public void create() { base.create(); rollIndicators = new FlxGroup(); framesElapsed = 0; selected = 0; suggestionForClubNoted = false; suggestionForForceNoted = false; suggestionForClubStatus = 0; suggestionForForceStatus = 0; selectedClub = 0; playAgainSelected = 0; Globals.ballInHole = false; //"Sand Wedge" } clubs = new List <string> { "Putter", "1 Wood", "3 Wood", "5 Wood", "1 Iron", "2 Iron", "3 Iron", "4 Iron", "5 Iron", "6 Iron", "7 Iron", "8 Iron", "9 Iron" }; //, "Chip Shot", "Pitch", "Fade", "Draw", "Lay-up", "Knock Down", "Flop" force = new List <string> { "Feather Touch", "Firm Putt", "Power Drive" }; playAgain = new List <string> { "Yes", "No", "Skip Hole +9" }; game = new FlxSprite(0, 0); game.loadGraphic("putt/bg", true, false, 256, 224); game.boundingBoxOverride = false; add(game); ball = new Ball(FlxG.width / 2 - 8, FlxG.height - 24); hole = new Hole(FlxG.width / 2, FlxG.height / 2); // load the level. loadOgmo(); add(hole); add(ball); lee = new Lee(FlxG.width / 6, FlxG.height - 170); add(lee); aim = new Aim(1, FlxG.height / 2); aim.y = hole.y - aim.width; add(aim); power = new FlxBar(FlxG.width - 110, FlxG.height - 30, FlxBar.FILL_LEFT_TO_RIGHT, 80, 8, null, "", 0, 50, true); add(power); power.visible = false; power.useCustomColors = true; sound = new FlxSound(); sound.loadEmbedded(Globals.ContentFolder + "/sfx/welcome", false); if (Globals.hole == 1) { sound.play(); } actionButton = new ActionButton(FlxG.width - 40, FlxG.height - 40); actionButton.visible = false; add(actionButton); if (FlxG.debug && Globals.platform == "Touch") { FlxG.mouse.show(); } if (Globals.platform == "Touch") { actionButton.visible = true; } add(rollIndicators); carPark = new CarPark(0, 0); carPark.visible = false; add(carPark); text = new FlxText(22, 16, 200); text.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.Yellow, FlxJustification.Left, Color.Black); add(text); subtitle = new FlxText(22, 2, FlxG.width); subtitle.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.White, FlxJustification.Left, Color.Black); add(subtitle); activator = new Carrot((int)text.x - 11, (int)text.y); //activator.createGraphic(8, 8, Color.Violet); activator.visible = false; add(activator); log("Welcome to " + Globals.GameNameSplit); if (Globals.pirate && Globals.hole >= 4) { #if !__IOS__ FlxU.openURL("http://initialsgames.com/"); FlxG.Game.Exit(); #endif } }