User Tools

Site Tools

Accessing the Scroll class from a ScrollObject

Being able to access common functions in the Scroll class is pretty essential in a Orx/Scroll based game. The Scroll class provides a singleton which can be accessed from anywhere in a ScrollObject class:

MyClass::GetInstance()

Imagine for a second that you had a function in your Scroll class to update a score. Collisions using OnCollide in the various instances of ScrollObject(s) might all need to update the score with different values.

Let's say the score function looks like this in the MyGameScroll class:

void MyGame::AddToScore(int points){
score += points;}

And say we had a Hero ScrollObject class which happened to collide with a Coin ScrollObject class: