Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6913273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:11:50+00:00 2026-05-27T09:11:50+00:00

Problem is in my class that renders the level that needs some value to

  • 0

Problem is in my class that renders the level that needs some value to render the side scrolling and this value im getting inside the player class.. And when i make something like:

//Inside the render class
//This is global variable
Player player = new Player;

//This is inside some method that renders.
public void rendering method()
{
int i = player.myInt;
}

Int i is always zero.. Even i update myInt inside the player class every time the right button is pressed.

I also tried making a method that returns the value i need:

//Inside the player class
public int testing()

{
      return myValue;
}

This is also not working correctly..

Inside my Player class i have the variable inside the constructor like:

public Player()
{
myValue = 0;
}

And then inside a update method inside the player class that gets called to look for keypresses i have:

public void Update()
{
 if(key left was pressed)
    myValue--;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:11:51+00:00Added an answer on May 27, 2026 at 9:11 am

    Make sure you are using the correct format.

    For example:

    class Player: Form
    {
        public static int myInt = 0;    //This is where the next screen should be.
    
        /// <summary>
        /// Constructor.
        /// </summary>
        public Player()
        {
        }
    
    
    
        /// <summary>
        /// Changes MyInt.  Increments myInt so the next corod
        /// </summary>
        private void ButtonPressed()
        {
            myInt++;
            //Note, you need to get the screen size and mode it with this to prevent setting the location off screen.
    
        }
    }
    
    class Render
    {
        private Player player;  //Class variable so it persists between calls
    
        /// <summary>
        /// Constructor.  Sets player.
        /// </summary>
        public Render()
        {
            Location = new Point(Player.myInt, Player.myInt);           //Set my coordinate
        }
    
        /// <summary>
        /// Shows the value of this.player.MyInt in a message box.
        /// </summary>
        public void rendering_method()
        {
            int i = Player.myInt;
    
            MessageBox.Show("The value is: " + i);
        }
    }
    

    If that does not resolve your problem then we will need more info.
    It would be best if you could put up the two classes affected.

    Updated to set Player location using constructor.
    Updated based on updated content in original question. What is the object hierarchy? Will the Player be creating the Render class?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this must be a common problem. I've got a class that in
I have a class that i want to push_back into a deque. The problem
I have a class that is mapped to a table using NHibernate. The problem
i have a problem calling multiple instance of a class that i have coded
I call addNotify() method in class that I posted here. The problem is, that
Problem in words: For my application, I have a class that reads from a
My problem is that in my Widget class i've the following declaration: MouseEvent* X;
I have the problem that my view controller class has too many delegates and
I need to create class Dog and PurebredDog extending Dog. Problem is that Dog
Today I ran into the following problem with NUnit. I have a class, that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.