Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

error CS0120: An object reference is required to access non-static member `Groups.numberOfRowsThisTurn'

$
0
0
I am adding scoring to my Tetris game and received this error, Assets/Groups.cs(79,17): error CS0120: An object reference is required to access non-static member `Groups.numberOfRowsThisTurn'. I have tried to look it up online but I still can't figure out what the problem is. Please help. Here is my code: using UnityEngine; using System.Collections; using UnityEngine.UI; public class Groups : MonoBehaviour { public static int gridWidth = 10; public static int gridHeight = 20; public static Transform[,] grid = new Transform[gridWidth, gridHeight]; public int scoreOneLine = 40; public int scoreTwoLine = 100; public int scoreThreeLine = 300; public int scoreFourLine = 1200; public Text hub_score; private static int numberOfRowsThisTurn = 0; private int CurrentScore; void update() { updateScore (); updateUI (); } public void updateUI() { hub_score.text = CurrentScore.ToString (); } public void updateScore(){ if (numberOfRowsThisTurn > 0) { if (numberOfRowsThisTurn == 1) { clearedOneLine (); } else if (numberOfRowsThisTurn == 2) { clearedTwoLines (); } else if (numberOfRowsThisTurn == 3) { clearedThreeLines (); } else if (numberOfRowsThisTurn == 4) { clearedFourLines (); } numberOfRowsThisTurn = 0; } } void clearedOneLine(){ CurrentScore += scoreOneLine; } void clearedTwoLines(){ CurrentScore += scoreTwoLine; } void clearedThreeLines(){ CurrentScore += scoreThreeLine; } void clearedFourLines(){ CurrentScore = +scoreFourLine; } public static Vector2 round(Vector2 v) { return new Vector2(Mathf.Round(v.x), Mathf.Round(v.y)); } public static bool isInsideGrid(Vector2 pos) { return ((int)pos.x >= 0 && (int)pos.x < gridWidth && (int)pos.y >= 0); } public static void Delete(int y) { for (int x = 0; x < gridWidth; ++x) { Destroy(grid[x, y].gameObject); grid[x, y] = null; } } public static bool isFull(int y) { for (int x = 0; x < gridWidth; ++x) { if (grid [x, y] == null) { return false; } } numberOfRowsThisTurn ++; return true; }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>