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.


Topics - mastodona7x

Pages: [1]
1
Graphics / sprite being drawn twice on top of each other?
« on: July 08, 2012, 02:26:00 pm »
Hi all, I have a strange problem where in my bomberman type game I'm making, when you lay a bomb, it appears very rough around the edges. Testing in photoshop it looks like the png is being layered on top of its self twice on the window.draw(*bomb). I can tell this because the flame which is semi transparent is very dark compared to just manually placing the bomb on the field. (See pic please - I've enlarged this to make it clearer).
Has anyone come across this before and/or could suggest why this might be happening? I have tested and know only 1 bomb is being layed when space bar is pressed, so why the double texture?

Note the left bomb is a sprite I manually created and placed , the right one is one "layed" in the game by pressing spacebar, and as I say it is only 1 object...


2
Graphics / Texture won't display when loaded from within a class?
« on: July 07, 2012, 06:05:48 pm »
Hello all,  :)

Total noobie here but Im trying to create a simple game. I want to create a bomb object and everything is fine if I set the bomb up from within the main() loop, but if I try to make a bomb class then create a new bomb from this class, the texture no longer loads, I just get a white square instead. Can anyone help see why please?
Also can I pass a sf::IntRect() over the the class instead of having to pass over 4 individual ints? I tried changing the bomb class to get sf::IntRect textureRect and passing sf::IntRect(0,0,32,32) in the call but I just could not get it to work, so I am not sure if this is possible?

Main worry is the lack of texture anyway, like I say if I have the bomb created in main it shows the png bomb just fine, any suggestions most appreciated thanks.  :)

Code so far:

call top create new bomb instance in main()
Bomb bomb(0,0,32,32,0,0,64,64,160,160); // would rather pass some IntRects so neaten this up!
 


In bomb class (bomb.h):
public:
  Bomb(int texureRectX, int textureRectY, int textureRectSizeX, int textureRectSizeY, int collisionRectX, int collisionRectY, int collisionRectSizeX, int collisionRectSizeY, int posX, int posY )
  {
         this->setTextureRect(sf::IntRect(0,0,32,32));
         this->setRelativeCollider(sf::IntRect(0,0,64,64));
         this->setPosition(160, 160);
         sf::Texture bombChar;
         bombChar.loadFromFile("images/bomb.png");
         this->setTexture(bombChar);
  };
 

Pages: [1]
anything