### Replacement for mBounds.point

Expanding and utilizing the engine via C++.

#### Replacement for mBounds.point

Tiel
Posts: 25
Joined: Tue Mar 01, 2016 11:39 pm
A resource I'm trying to port has the lines
// projected point
mPtScreen = mPtProj;

// alignment offset
mPtScreen += offsetAlign;

// screen offset
mPtScreen += mOffsetScreen;

// setTrgPosition(mPtScreen);
mBounds.point=mPtScreen;
Problem being mBounds is private as of a few years ago. I'm not even going to pretend I'm comfortable with C++, but from what I've gathered this last line is to set the position of the control via mBounds.point (which is the topleftcorner of a ctrl to the best of my knowledge, forgive my ignorance). So getExtent() or getBounds, the replacement for retrieving extents with mBounds, wouldn't exactly work here, as those are functions that return a value, not the other way around.

Getting to the point, is there a replacement for mBounds.point?

#### Re: Replacement for mBounds.point

JeffR
Steering Committee
Posts: 813
Joined: Tue Feb 03, 2015 9:49 pm

If you're only trying to set the position of the gui control, you should be able to just call setPosition(mPtScreen);

if you poke through gui/core/guiControl.h, that's the header of the root gui object class, and that sucker has a ton of useful utility functions for doing basic stuff like this.

Lemme know if that doesn't work, but that should do what you need.

#### Re: Replacement for mBounds.point

Tiel
Posts: 25
Joined: Tue Mar 01, 2016 11:39 pm
Okay, that seemed to please it.

Although, if I might go offtopic, I've also been trying to get this guy to work: http://www.garagegames.com/community/fo ... ead/107847
// If we're mounted to them, don't give them anything!
ShapeBase* obj = this;
while(obj->getObjectMount())
if((SceneObject*)obj->getObjectMount() == convex->getObject())
return;
else
obj = obj->getObjectMount();

error C2440: '=' : cannot convert from 'SceneObject *' to 'ShapeBase *'

What I'm trying to do is mount staticshapes to an AIPlayer but it sounds like the collision's immobilizing them.

#### Re: Replacement for mBounds.point

JeffR
Steering Committee
Posts: 813
Joined: Tue Feb 03, 2015 9:49 pm

That'd be because getObjectMount() returns a sceneObject, which isn't necessarily a ShapeBase object.

You'll either want your initial ShapeBase* obj = this; to instead read SceneObject* obj = this;, so you can handle ANY scene object that may be mounted, or if you just assume the only things you'll be mounting are other ShapeBase objects, you can turn that last line into:

Code: Select all

obj = dynamic_cast<ShapeBase*>(obj->getObjectMount()); 
Which will try casting obj to a ShapeBase. If one of the mounted objects isn't a shapebase or derived from it, that approach could cause problems/crashes though, so be wary.

#### Who is online

Users browsing this forum: No registered users and 2 guests