Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is in the form class:
- public static void notifyChange()
- {
- //Error here: "An object reference is required for the non-static field, method, or property
- //'Level_Editor.MapEditor.ChangeIndicator'
- ChangeIndicator.Text = status;
- }
- //Here's the code in the XNA game that needs to use notifyChange to change the text in the form:
- //if the mouse coordinates for the world are actually in the world...
- if (Camera.WorldRectangle.Contains((int)mouseLoc.X, (int)mouseLoc.Y))
- {
- //if the left button is pressed...
- if (ms.LeftButton == ButtonState.Pressed)
- {
- isChanged = true;
- MapEditor.notifyChange();
- //Place tile at cell pointed at by the mouse
- TileMap.SetTileAtCell(
- TileMap.GetCellByPixelX((int)mouseLoc.X),
- TileMap.GetCellByPixelY((int)mouseLoc.Y),
- DrawLayer, DrawTile);
- }
- //if we pressed the right-mouse button & we have not been holding it down...
- if ((ms.RightButton == ButtonState.Pressed) &&
- (lastMouseState.RightButton != ButtonState.Released))
- {
- isChanged = true;
- MapEditor.notifyChange();
- //if we are also in Code Editing mode...
- if (EditingCode)
- {
- //Set the code value of the selected tile to the current code value
- // within the editor window
- TileMap.GetMapSquareAtCell(
- TileMap.GetCellByPixelX((int)mouseLoc.X),
- TileMap.GetCellByPixelY((int)mouseLoc.Y)
- ).CodeValue = CurrentCodeValue;
- }
- else
- {
- //Check the tile chosen upon click then paint the opposite of it
- if (!painting)
- {
- paintType = !(TileMap.GetMapSquareAtCell(
- TileMap.GetCellByPixelX((int)mouseLoc.X),
- TileMap.GetCellByPixelY((int)mouseLoc.Y)
- ).Passable);
- painting = true;
- }
- if (painting)
- {
- TileMap.GetMapSquareAtCell(
- TileMap.GetCellByPixelX((int)mouseLoc.X),
- TileMap.GetCellByPixelY((int)mouseLoc.Y)
- ).Passable = paintType;
- }
- }
- }
- if (ms.RightButton == ButtonState.Released)
- {
- painting = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement