Jump to content

Replacement for mBounds.point


Recommended Posts

Posted

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?

Posted

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.

Posted

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/forums/viewthread/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();

 

This displeases the compiler:


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.

Posted

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:

 

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...