Hello,
I'm trying to get position and size of sprite and texture but I'm getting this error:
error is on wsprintf...
Unhandled exception at 0x74df9d60 in Lucid Dreaming.exe: 0xC0000005: Access violation reading location 0x00000320.
part of code:
Vector2u PlayerSize = tBackground[0].getSize();
char test[512];
wsprintf(test, "%s", PlayerSize);
MessageBox(NULL, test, NULL, NULL);
and position is returnin NULL value
Vector2f PlayerPosition = sBackground.getPosition();
char test[512];
wsprintf(test, "%s", PlayerPosition);
MessageBox(NULL, test, NULL, NULL);
also is there any way to return them as int x,y?
What you want is to use either %u (unsigned integer) or %f (float) for each of the X and Y values in the vector.
For example:
Vector2u PlayerSize = tBackground[0].getSize();
char test[512];
wsprintf(test, "%u, %u", PlayerSize.x, PlayerSize.y);
MessageBox(NULL, test, NULL, NULL);
Or better: use the C++ functions instead of this unsafe C stuff.
std::ostringstream oss;
oss << PlayerSize.x << PlayerSize.y;
std::string str = oss.str();