Joined
·
4,410 Posts
Hey guys, wuddup?
This is my first time posting in this section. I've gotten quite serious with my C++ towards Game Programming.
Anyway, I've been having a problem with some code using cocos2d-x, but I'm sure anyone with a grasp of C++ could assist me here.
My objective is simple. I want to pass accelerometer values to a text label. For debug purpose you could say.
I have a function for obtaining the values. Something like:
Void onAcceleration (cocos2d::Acceleration* acc, Event* event)
[
Float x = acc->x;
]
That's basically it.
Now in a text function in the main(), I want to pass that x variable to the label, so I use StringUtils::toString(or format, any one).
The problem now is this. That x value is out of scope. Can't access it.
If I change the function to a float, and return a float variable, and try and equate a new variable to the returned 'x' of the function, I can get quite a few errors.
If i use the function without () : argument list is missing.
If I use with blank () : function does not take 0 arguments.
I don't see what I'm meant to put into the parentheses.
As well, if I try initializing the acc function straight in the main, it plain doesn't work.
If anything is unclear, tell me and I'll clarify. Hoping I didn't leave anything out... Just holla if I did.
This is my first time posting in this section. I've gotten quite serious with my C++ towards Game Programming.
Anyway, I've been having a problem with some code using cocos2d-x, but I'm sure anyone with a grasp of C++ could assist me here.
My objective is simple. I want to pass accelerometer values to a text label. For debug purpose you could say.
I have a function for obtaining the values. Something like:
Void onAcceleration (cocos2d::Acceleration* acc, Event* event)
[
Float x = acc->x;
]
That's basically it.
Now in a text function in the main(), I want to pass that x variable to the label, so I use StringUtils::toString(or format, any one).
The problem now is this. That x value is out of scope. Can't access it.
If I change the function to a float, and return a float variable, and try and equate a new variable to the returned 'x' of the function, I can get quite a few errors.
If i use the function without () : argument list is missing.
If I use with blank () : function does not take 0 arguments.
I don't see what I'm meant to put into the parentheses.
As well, if I try initializing the acc function straight in the main, it plain doesn't work.
If anything is unclear, tell me and I'll clarify. Hoping I didn't leave anything out... Just holla if I did.