コード例 #1
0
        public PauseState(StateStack stack, Context context)
            : base(stack, context)
        {
            RenderWindow window = mContext.window;

            mBackgroundSprite = new Sprite();
            mPausedText = new Text();
            mInstructionText = new Text();

            mPausedText.Font = mContext.fonts.get(FontID.Main);
            mPausedText.DisplayedString = "Game Paused";
            mPausedText.CharacterSize = 70;
            mPausedText.centerOrigin();
            mPausedText.Position = new Vector2f(0, 0);

            mInstructionText.Font = mContext.fonts.get(FontID.Main);
            mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
            mInstructionText.centerOrigin();
            mInstructionText.Position = new Vector2f(0, 0);

            backgroundShape = new RectangleShape();
            backgroundShape.FillColor = new Color(0, 0, 0, 150);
            backgroundShape.Position = window.GetView().Center;
            backgroundShape.centerOrigin();
            backgroundShape.Size = window.GetView().Size;
        }
コード例 #2
0
ファイル: TitleState.cs プロジェクト: pixeltasim/Conform
        public TitleState(StateStack stack, Context context)
            : base(stack, context)
        {
            starttimer = new Clock();
            starttimer.Restart();

            titletext = new Text();
            titletext.Scale = new Vector2f(2, 2);
            titletext.DisplayedString = "PIXELTASIM";
            titletext.Font = mContext.mFonts.get(FontID.Title);
            titletext.centerOrigin();
            titletext.Position = new Vector2f(mContext.mWindow.Size.X/2, mContext.mWindow.Size.Y / 8);
            titletext.Color = Color.Black;

            square = new RectangleShape(new Vector2f(UnitConverter.toPixScale(0.5f), UnitConverter.toPixScale(0.5f)));
            square.centerOrigin();
            square.FillColor = Color.Red;
            square.OutlineColor = Color.Black;
            square.OutlineThickness = 1;

            b2World = new World(new Vec2(0, 10), false);
            BodyDef b2Def = new BodyDef();
            b2Def.BodyType = BodyType.Dynamic;
            b2Def.Position = new Vec2(UnitConverter.toSimScale(mContext.mWindow.Size.X / 2), UnitConverter.toSimScale(mContext.mWindow.Size.Y / 8*3));
            b2Body = b2World.CreateBody(b2Def);

            PolygonShape dynamicbox = new PolygonShape();
            dynamicbox.SetAsBox(UnitConverter.toSimScale(32), UnitConverter.toSimScale(32));

            FixtureDef fixDef = new FixtureDef();
            fixDef.Shape = dynamicbox;
            fixDef.Density = 1;
            fixDef.Friction = 0.3f;
            b2Body.CreateFixture(fixDef);

            square.Position = new Vector2f(UnitConverter.toPixScale(b2Body.Position.X), UnitConverter.toPixScale(b2Body.Position.Y));
        }