Search Results

Search found 2 results on 1 pages for 'user1090751'.

Page 1/1 | 1 

  • Texture not rendering in correct order in xna 4?

    - by user1090751
    I am making a simple board game. In the game there is a fixed background called myTexture and others are textureGoat and textureTiger whicha are to be placed on top of the background(myTexture). But i am having problem that fourth and fifth component is not displaying however, the sixth component( i.e. myTexture) is appearing. Here is my code, please look at it protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Green); // TODO: Add your drawing code here spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); //placing tiger spriteBatch.Draw(textureTiger, new Rectangle(22, 25, 50, 50), Color.White);//first component spriteBatch.Draw(textureTiger, new Rectangle(22, 407, 50, 50), Color.White);//second component spriteBatch.Draw(textureTiger, new Rectangle(422, 25, 50, 50), Color.White);//third component spriteBatch.Draw(textureTiger, new Rectangle(422, 407, 50, 50), Color.White);//fourth component //placing goat spriteBatch.Draw(textureGoat, new Rectangle(125, 110, 50, 50), Color.White);//fifth component //placing background spriteBatch.Draw(myTexture, new Rectangle(0, 0, 500, 500), Color.White);//sixth component spriteBatch.End(); base.Draw(gameTime); }

    Read the article

  • If and else condition not working properly in xna [closed]

    - by user1090751
    I am developing chess like game and i wanted to show error message if user try to place any player inside the box which is not empty. For example in certain place if there is empty then the object(2d object) is placed else it should show error message. However in my program it is showing message everytime i.e when i place object on empty place then also it is showing error message. Please see the below code: protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here for (int i = 0; i < 25; i++) { MouseState mouseState; mouseDiBack = false; mouseState = Mouse.GetState(); if (new Rectangle(mouseState.X, mouseState.Y, 1, 1).Intersects(rect_arr[i])) { background_color_arr[i] = Color.Red; } else { background_color_arr[i] = Color.White; } if (new Rectangle(mouseState.X, mouseState.Y, 1, 1).Intersects(rect_arr[i]) && (mouseState.LeftButton == ButtonState.Pressed)) { if (boxes[i] != "goat" && boxes[i] != "tiger") { place = i; if (turn == "goat") { boxes[i] = "goat"; turn = "tiger"; } else { boxes[i] = "tiger"; turn = "goat"; } } else { errMsg = "This " + i + " block is not empty to place " + turn + ". Please select empty block!!"; } } } base.Update(gameTime); }

    Read the article

1