示例#1
0
 public Context(RenderWindow window, ResourceHolder<Texture, ResourceID> textures, ResourceHolder<Font, FontID> fonts, Player player) 
 {
     this.window = window;
     this.textures = textures;
     this.fonts = fonts;
     this.player = player;
 }
        public GameApplication()
        {
            mWindow = new RenderWindow(new VideoMode(640, 480), "SFML App", Styles.Close);
            mWindow.SetKeyRepeatEnabled(false);

            mPlayer = new Player();

            mTextures = new ResourceHolder<Texture, ResourceID>();
            mTextures.load(ResourceID.TitleScreen, "Media/Textures/TitleScreen.png");
            mTextures.load(ResourceID.ButtonNormal, "Media/Textures/ButtonNormal.png");
            mTextures.load(ResourceID.ButtonSelected, "Media/Textures/ButtonSelected.png");
            mTextures.load(ResourceID.ButtonPressed,"Media/Textures/ButtonPressed.png");

            mFonts = new ResourceHolder<Font, FontID>();
            mFonts.load(FontID.Main, "Media/Sansation.ttf");

            mStateStack = new StateStack(new State.Context(mWindow,mTextures,mFonts,mPlayer));
            eventqueue = new Queue<Event>();

            registerStates();
            mStateStack.pushState(StateID.Title);

            mWindow.Closed += onClosed;
            mWindow.GainedFocus += gainedFocus;
            mWindow.LostFocus += lostFocus;
            mWindow.KeyPressed += keyPressed;
        }
示例#3
0
        public Game()
        {
            mWindow = new RenderWindow(new VideoMode(640, 480), "SFML App", Styles.Close);

            mWorld = new World(mWindow);
            commmands = mWorld.getCommandQueue();
            mPlayer = new Player(commmands);//possibly initialized in World?
            eventqueue = new Queue<Event>();

            mWindow.Closed += onClosed;
            mWindow.GainedFocus += gainedFocus;
            mWindow.LostFocus += lostFocus;
            mWindow.KeyPressed += keyPressed;
        }
        private void addButtonLabels(Player.Action action, float y, string text, Context context)
        {
            mBindingButtons[(int)action] = new Button(context.fonts,context.textures);
            mBindingButtons[(int)action].Position = new Vector2f (80,y);
            mBindingButtons[(int)action].setText(text);
            mBindingButtons[(int)action].setToggle(true);
            mBindingButtons[(int)action].setCallback(() =>
            {
                
            });

            mBindingLabels[(int)action] = new Label("", context.fonts);
            mBindingLabels[(int)action].Position = new Vector2f(300, y+ 15);

            mGUIContainer.pack(mBindingButtons[(int)action]);
            mGUIContainer.pack(mBindingLabels[(int)action]);
        }