Original Post
[font="Consolas"][font="Consolas"]
[/font][/font][font="Calibri"]Hi,[/font]
[font="Times New Roman"][/font][font="Calibri"] [/font]
[font="Calibri"]For learningpurposes I am trying to create a class named “World”, this class containsparameters like gravity and wind speed. The next step is the creation of aclass named “Sprite”, this would the class for my player (with player position,health,…). What I would like to do is to “attach” the player to the world,i.e., when creating an instance of “Sprite” I want to refer to which “World” (whichinstance of World class) the “Sprite” belongs to. What is the best approach fordoing this? Would World be a parent class of Sprite? How do I list the worldinstance as a parameter in the constructor of the sprite class in a way that ithas to show to which world the sprite belongs to.[/font]
[font="Times New Roman"][/font][font="Calibri"]Thanks,[/font]
[font="Times New Roman"][/font][font="Consolas"][font="Consolas"][/font][/font]
[/font][/font][font="Calibri"]Hi,[/font]
[font="Times New Roman"][/font][font="Calibri"] [/font]
[font="Calibri"]For learningpurposes I am trying to create a class named “World”, this class containsparameters like gravity and wind speed. The next step is the creation of aclass named “Sprite”, this would the class for my player (with player position,health,…). What I would like to do is to “attach” the player to the world,i.e., when creating an instance of “Sprite” I want to refer to which “World” (whichinstance of World class) the “Sprite” belongs to. What is the best approach fordoing this? Would World be a parent class of Sprite? How do I list the worldinstance as a parameter in the constructor of the sprite class in a way that ithas to show to which world the sprite belongs to.[/font]
[font="Times New Roman"][/font][font="Calibri"]Thanks,[/font]
[font="Times New Roman"][/font][font="Consolas"][font="Consolas"][/font][/font]