Hello. I am new to both C++ and C# but have been trying to convert C++ tutorial info to C# so my code may be very flawed or imperfect. My issue is that the loaded music begins playing as planned but suddenly stops and does not restart. The stopping point seems to be different each time I execute (from debug or application). Using VS2015. Most likely as a result of being new to SFML and C#, I am missing something basic. I appreciate any assistance.
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;using SFML;using SFML.Graphics;using SFML.Audio;using SFML.Window;namespace LurkingII
{ static class Program
{ static void OnClose
(object sender, EventArgs e
) { // Close the window when OnClose event is received RenderWindow window
= (RenderWindow
)sender
; window
.Close(); } static void MenuView_MouseMoved
(object sender, MouseMoveEventArgs e
) { } static void MenuView_MouseButtonPressed
(object sender, MouseButtonEventArgs e
) { } static void Main
() { // Create the main window RenderWindow MenuView
= new RenderWindow
(new VideoMode
(1280,
720),
"Lurking II: A Madness", Styles
.Fullscreen); // Add event handling MenuView
.Closed += new EventHandler
(OnClose
); MenuView
.MouseMoved += MenuView_MouseMoved
; MenuView
.MouseButtonPressed += MenuView_MouseButtonPressed
; Texture TitleBG
= new Texture
(@"C:\Users\Aaron\Desktop\Aaron\Lurking II\grfx\GAMEVIEW_GRFX\TitlePage_03_2018.bmp"); Sprite TitlePage
= new Sprite
(); TitlePage
.Texture = TitleBG
; Font L2Font
= new Font
(@"C:\Users\Aaron\Desktop\bardscroll.ttf"); Text DispText
= new Text
("NEW QUEST",L2Font,
16); DispText
.Position = new Vector2f
(1000,
400); Text DispText2
= new Text
("RESUME QUEST", L2Font,
16); DispText2
.Position = new Vector2f
(1000,
450); Text DispText3
= new Text
("CHARACTERS", L2Font,
16); DispText3
.Position = new Vector2f
(1000,
500); Text DispText4
= new Text
("QUIT", L2Font,
16); DispText4
.Position = new Vector2f
(1000,
550); //Play Music Music CurrentSong
= new Music
(@"C:\Users\Aaron\Desktop\Vermys Score\Title.ogg"); CurrentSong
.Play(); // Start the game loop while (MenuView
.IsOpen()) { // Process events MenuView
.DispatchEvents(); // Display Title Screen Texture MenuView
.Draw(TitlePage
); // GET THE MOUSE POSITION Vector2i mouseP
= new Vector2i
(); mouseP
= Mouse
.GetPosition(MenuView
); Vector2f mousePC
= new Vector2f
(); mousePC
= MenuView
.MapPixelToCoords(mouseP
); // Reset menu items DispText
.Color = new Color
(50,
50,
50); DispText2
.Color = new Color
(50,
50,
50); DispText3
.Color = new Color
(50,
50,
50); DispText4
.Color = new Color
(50,
50,
50); FloatRect Textbb
= new FloatRect
(); Textbb
= DispText
.GetGlobalBounds(); FloatRect Text2bb
= new FloatRect
(); Text2bb
= DispText2
.GetGlobalBounds(); FloatRect Text3bb
= new FloatRect
(); Text3bb
= DispText3
.GetGlobalBounds(); FloatRect Text4bb
= new FloatRect
(); Text4bb
= DispText4
.GetGlobalBounds(); // Color active menu option if (Textbb
.Contains(mouseP
.X, mouseP
.Y)) { DispText
.Color = new Color
(120,
120,
120); } if (Text2bb
.Contains(mouseP
.X, mouseP
.Y)) { DispText2
.Color = new Color
(120,
120,
120); } if (Text3bb
.Contains(mouseP
.X, mouseP
.Y)) { DispText3
.Color = new Color
(120,
120,
120); } if (Text4bb
.Contains(mouseP
.X, mouseP
.Y)) { DispText4
.Color = new Color
(120,
120,
120); } // Display Menu Text MenuView
.Draw(DispText
); MenuView
.Draw(DispText2
); MenuView
.Draw(DispText3
); MenuView
.Draw(DispText4
); // Update the window MenuView
.Display(); } //End game loop } //End Main() } //End Program } //End Lurking II Namespace