• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

how remove a model

8 posts in this topic

but i don´t know how remove the model

i find soluction

with this code


Edited by Landi20

Share this post

Link to post
Share on other sites

i make logout and go to login class i don´t want show the model as been create in world class


logout and login from where? what world class? are you using a game engine?


(It seems you're having trouble explaining your problem in english, are you portuguese (in your profile it says you're in Viana do Castelo)? If so, send me a private message with your question in portuguese and I'll try to help you)


Share this post

Link to post
Share on other sites

i find the soluction i only have to add a new line of code




I have no idea what language or library you are using, but be careful of calling a method like remove() with a this pointer or reference. If you access any members of the object following that line, it is likely to crash your application (depending on what language you are using).


C++ example:

ListOfThings things;

void removeThing(Thing *t)

class Thing
    void destroyMe()
        print(health); // crash, this points to deallocated memory

    int health;

It is normally better to remove things at a higher level than have an instance remove itself from a container.


Share this post

Link to post
Share on other sites

No idea how C# handles this. Guess since it is garbage collected, the instance will still exist for the rest of the method so you're probably okay. Its just conceptually confusing to have objects delete themselves generally speaking.


Share this post

Link to post
Share on other sites

when i use this Game.GameSystems.Remove(this);

the game gets completely crazy

my buttons start flashing for wile and stop

this is code for world class

using System;
using SharpDX;
using SharpDX.Toolkit;
using System.Collections.Generic;
using SharpDX.Toolkit.Input;
using TomShane.Neoforce.Controls;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.Toolkit.Content;
using SharpDX.Toolkit.Graphics;
using System.Text;
using SharpDX.Windows;

namespace TomShane.Neoforce.Central
    internal sealed class World : GameSystem
        private Manager NeoManager;
        string texto;
        private SpriteBatch spriteBatch;
        private SpriteFont arial16BMFont;
       // private PointerManager pointer;
        private Model model;
        private List<Model> models;
        private BoundingSphere modelBounds;
        private Matrix world;
        private Matrix view;
        private Matrix projection;
        private Window inventory;
        private Window Charactersstatus;
        private Window gameexit;
        TomShane.Neoforce.Controls.Console con1;
        TomShane.Neoforce.Controls.Console con2;
        private Game _game=null;
        int i = 0;

        private TomShane.Neoforce.Controls.TabControl tbc;
        public World(Game game, Manager ola, string text)
            : base(game)
            _game =game;
            NeoManager = ola;
            texto = text;
           // pointer = new PointerManager(game);

            // this game system has something to draw - enable drawing by default
            // this can be disabled to make objects drawn by this system disappear
            Visible = true;

            // this game system has logic that needs to be updated - enable update by default
            // this can be disabled to simulate a "pause" in logic update
            Enabled = true;

            // add the system itself to the systems list, so that it will get initialized and processed properly
            // this can be done after game initialization - the Game class supports adding and removing of game systems dynamically

           // NeoManager = new Manager(game);

        /// <summary>
        /// Initialize here anything that depends on other services
        /// </summary>
        public override void Initialize()

          //  NeoManager.Initialize();

            // get the camera service from service registry

        private void HandlePlayerInput()
            KeyboardState currentKeyboardState = NeoManager.KeyboardManager.GetState();

            if (currentKeyboardState.IsKeyDown(Keys.A))

            if (currentKeyboardState.IsKeyDown(Keys.D))


            if (currentKeyboardState.IsKeyDown(Keys.W))


            if (currentKeyboardState.IsKeyDown(Keys.S))

            if (currentKeyboardState.IsKeyPressed(Keys.I))

            if (currentKeyboardState.IsKeyDown(Keys.C))

            if (currentKeyboardState.IsKeyDown(Keys.Escape))


            if (currentKeyboardState.IsKeyDown(Keys.Space))

            if (currentKeyboardState.IsKeyDown(Keys.M))


        private void Inventory()
            inventory = new Window(NeoManager);
            inventory.Text = "Inventory";
            inventory.Width = 450;
            inventory.Height = 250;
            inventory.Visible = true;
            inventory.CloseButtonVisible = true;
            inventory.Resizable = false;
            inventory.Movable = true;
            inventory.IconVisible = false;

        private void ExitGamer()
            gameexit = new Window(NeoManager);
            gameexit.Text = "Game Exit";
            gameexit.Width = 200;
            gameexit.Height = 220;
            gameexit.Visible = true;
            gameexit.CloseButtonVisible = true;
            gameexit.Resizable = false;
            gameexit.Movable = true;
            gameexit.IconVisible = false;
            Button Sair = new Button(NeoManager);
            Sair = new Button(NeoManager);
            Sair.Width = 80;
            Sair.Parent = gameexit;
            Sair.Left = 50;
            Sair.Top = 0;
            Sair.Text = "Quit";
            Sair.TextColor = new SharpDX.Color(250, 250, 250);
            Sair.Click += new Controls.EventHandler(btnExit_Click1);
            Button Logout = new Button(NeoManager);
            Logout = new Button(NeoManager);
            Logout.Width = 80;
            Logout.Parent = gameexit;
            Logout.Left = 50;
            Logout.Top = 40;
            Logout.Text = "Logout";
            Logout.TextColor = new SharpDX.Color(250, 250, 250);
            Logout.Click += new Controls.EventHandler(Logout_Click1);

            Button Characters = new Button(NeoManager);
            Characters = new Button(NeoManager);
            Characters.Width = 80;
            Characters.Parent = gameexit;
            Characters.Left = 50;
            Characters.Top = 80;
            Characters.Text = "Characters";
            Characters.TextColor = new SharpDX.Color(250, 250, 250);

            Button Options = new Button(NeoManager);
            Options = new Button(NeoManager);
            Options.Width = 80;
            Options.Parent = gameexit;
            Options.Left = 50;
            Options.Top = 120;
            Options.Text = " Options";
            Options.TextColor = new SharpDX.Color(250, 250, 250);

            Button Canceling = new Button(NeoManager);
            Canceling = new Button(NeoManager);
            Canceling.Width = 80;
            Canceling.Parent = gameexit;
            Canceling.Left = 50;
            Canceling.Top = 160;
            Canceling.Text = "Cancel";
            Canceling.ModalResult = ModalResult.Cancel;
            Canceling.TextColor = new SharpDX.Color(250, 250, 250);
        private void charactersstatus()
            Charactersstatus = new Window(NeoManager);
            Charactersstatus.Text = "Characters Status";
            Charactersstatus.Width = 450;
            Charactersstatus.Height = 250;
            Charactersstatus.Visible = true;
            Charactersstatus.CloseButtonVisible = true;
            Charactersstatus.Resizable = false;
            Charactersstatus.Movable = true;
            Charactersstatus.IconVisible = false;

        /// <summary>
        /// Load all graphics content here.
        /// </summary>
        protected override void LoadContent()

            arial16BMFont = Content.Load<SpriteFont>("Arial16");

            // Load the model (by default the model is loaded with a BasicEffect. Use ModelContentReaderOptions to change the behavior at loading time.
            models = new List<Model>();
            foreach (var modelName in new[] { "helmet" })
                model = Content.Load<Model>(modelName);

                // Enable default lighting  on model.
                BasicEffect.EnableDefaultLighting(model, true);

            model = models[0];

            // Instantiate a SpriteBatch
            spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));


            // InitRes();
            // initialize the basic effect (shader) to draw the geometry, the BasicEffect class is similar to one from XNA

        void btnExit_Click1(object sender, Controls.EventArgs e)
            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Do you really want to exit ", "", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)



        /// <summary>
        /// Draw the scene content.
        /// </summary>
        /// <param name="gameTime">Structure containing information about elapsed game time.</param>

        /// <summary>
        /// Update the scene logic.
        /// </summary>
        /// <param name="gameTime">Structure containing information about elapsed game time.</param>
        public override void Update(GameTime gameTime)
          // NeoManager.Update(gameTime);
            //var pointerState = pointer.GetState();
            //if (pointerState.Points.Count > 0 && pointerState.Points[0].EventType == PointerEventType.Released)
            //    // Go to next model when pressing key space
            //    model = models[(models.IndexOf(model) + 1) % models.Count];
           // Update(gameTime);
           /// Calculate the bounds of this model
            modelBounds = model.CalculateBounds();

            // Calculates the world and the view based on the model size
            const float MaxModelSize = 10.0f;
            var scaling = MaxModelSize / modelBounds.Radius;
            view = Matrix.LookAtRH(new Vector3(0, 0, MaxModelSize * 2.5f), new Vector3(0, 0, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, MaxModelSize * 10.0f);
            world = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z) * Matrix.Scaling(scaling) * Matrix.RotationY((float)gameTime.TotalGameTime.TotalSeconds);

            //if (con1.TextBoxVisible == true)
            //else {
           // model.Meshes.
         //   HandleInput();
            //  NeoManager.Update(gameTime);

            // get the total elapsed seconds since the start of the game


        private void HandleInput()
          // if (!con1.TextBoxVisible)
           // }
           // else
           // {
             //   con1.Focused = true;
                //Focused Input
           // }
        public override void Draw(GameTime gameTime)

          // GraphicsDevice.BlendStates.Opaque(gameTime);
            model.Draw(GraphicsDevice, world, view, projection);

            spriteBatch.DrawString(arial16BMFont, "Press the pointer to switch models...\r\nCurrent Model: " + model.Name, new Vector2(16, 16), Color.White);





     /*   public override void Draw3(GameTime gameTime)

           // NeoManager.BeginDraw(gameTime);
          ///  model.Draw(GraphicsDevice, world, view, projection);
          //  spriteBatch.Begin();

          //  spriteBatch.DrawString(arial16BMFont, "Press the pointer to switch models...\r\nCurrent Model: " + model.Name, new Vector2(16, 16), Color.White);

          //  spriteBatch.End();

          //  NeoManager.EndDraw();


        private void InitConsole(string texto)
            tbc = new TomShane.Neoforce.Controls.TabControl(NeoManager);
            con1 = new TomShane.Neoforce.Controls.Console(NeoManager);
            con2 = new TomShane.Neoforce.Controls.Console(NeoManager);

            tbc.Visible = true;
            //  con2.BackColor
            // Setup of TabControl, which will be holding both consoles

            tbc.Alpha = 220;
            tbc.Left = 0;
            tbc.Height = 220;
            tbc.Width = 450;
            tbc.Top = NeoManager.TargetHeight - tbc.Height - 32;

            tbc.Movable = true;
            tbc.Resizable = true;
            tbc.MinimumHeight = 96;
            tbc.MinimumWidth = 160;
           // tbc.TextColor= 
            tbc.TextColor = Color.White;
         //   NeoManager.Add(tbc);
            con1.Sender = texto;
            con2.Sender = texto;

            con2.Width = con1.Width = tbc.TabPages[0].ClientWidth;
            con2.Height = con1.Height = tbc.TabPages[0].ClientHeight;
            con2.Anchor = con1.Anchor = Anchors.All;

            con1.Channels.Add(new ConsoleChannel(0, "General", SharpDX.Color.Orange));
            con1.Channels.Add(new ConsoleChannel(1, "Private", SharpDX.Color.White));
            con1.Channels.Add(new ConsoleChannel(2, "System", SharpDX.Color.Yellow));
            con1.Channels.Add(new ConsoleChannel(3, "Guild", SharpDX.Color.Green));
            con1.Channels.Add(new ConsoleChannel(4, "Trade", SharpDX.Color.Red));

            // We want to share channels and message buffer in both consoles
            con2.Channels = con1.Channels;
            con2.MessageBuffer = con1.MessageBuffer;

            // In the second console we display only "Private" messages

            // Select default channels for each tab
            con1.SelectedChannel = 0;
            con2.SelectedChannel = 3;

            // Do we want to add timestamp or channel name at the start of every message?
            con1.MessageFormat = ConsoleMessageFormats.All;
            con2.MessageFormat = ConsoleMessageFormats.All;

            // Handler for altering incoming message
            con1.MessageSent += new ConsoleMessageEventHandler(con1_MessageSent);

            // We send initial welcome message to System channel
            con1.MessageBuffer.Add(new ConsoleMessage("System", "WELCOME TO THE SERVER! " + texto, 2));
            con1.Color = Color.Transparent;

        void con1_MessageSent(object sender, ConsoleMessageEventArgs e)
            if (e.Message.Channel == 0)
                //e.Message.Text = "(!) " + e.Message.Text;
        void Logout_Click1(object sender, Controls.EventArgs e)

            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Do you really want to exit ", "", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                Login ola = new Login(Game, NeoManager);
                ola.Visible = true;


Edited by Landi20

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0