1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
static int objCounter = 0;
Class::Class(){
//new object = +1 for the static object counter
objCounter++;
}
const static int arr[4][3] = {
//insert actual values here, each new row is a new object's values
//this is the only hardcoded part there is, which annoys me
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0}
}
//a very efficient way that I found to assign object values for every object created, as long as the array still has room of course
void Text::AssignVals(){
for(int i = 0; i < 20; i++){
//if the number of created objects is equal to the selected row in array
if(objCounter == i){
//any function goes here, just make sure to use the array's dimensions to assign values
text.setPosition(arr[i - 1][0], arr[i - 1][1]);
text.setCharacterSize(arr[i - 1][2]);
text.setRotation(arr[i][3]);
}
}
}
|