Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sammy

Pages: [1]
1
Graphics / Attaching image to a sprite
« on: February 06, 2011, 03:04:34 pm »
hmm, that were my solutions, too. but when executing the code line-by-line in visual studio, the GetImage-function is called properly and the right image is returned. but after calling the SetImage-method and befor the tempRes is deleted, the sprite contains no image. so as i concluded, the deleting of the tempRes can't cause this problem. or am i wrong?

@ nexus
yes your right, there is a lot of redundance in my code, i just have to simplify it... :roll:
the manager returns the base class, but it would be better to overload the GetRes-function

2
Graphics / Attaching image to a sprite
« on: February 06, 2011, 01:49:56 pm »
i'm sure that i just mad a very stupid mistake but i can't help myself
here's my code
Code: [Select]

void CDrawable::SetResource(std::string strID)
{
m_strResourceID = strID;

CResourceBMP* tempRes;
tempRes = static_cast<CResourceBMP* > (RESOURCEMANAGER->GetResource(m_strResourceID));
m_pSprite.SetImage(tempRes->GetImage());
delete tempRes;
tempRes = NULL;
}
//------------------------------------------------------
sf::Image CResourceBMP::GetImage()
{
return m_pImage;
}


The GetImage() method hands over a reference to its image, but m_pSprite just contains a NULL-pointer as image after calling SetImage() so that the programm just draws white rectangles or i get an acces violating.
the RESOURCEMANAGER stores the resources in a map, but its already completed when setting the resources to the objects. so it can't be an error cause of moving the image in memory because the vector/map expands.

i don't see the forrest because of all the trees, as you say here in Germany;)

Pages: [1]
anything