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 - programsfml

Pages: [1]
1
Hello. I have two sprites that I want to check for collision on. I was originally calling getGlobalBounds() on both sprites and checking if they intersected. This works fine except for the fact that the player sprites are holding a long weapon, so even if just their weapons are touching when attacking, it counts as collision. I want it so collision only happens when the weapon is hitting the other sprites body. Is there a way to get only a portion of the bounding box for a sprite and then see if it intersects with the other sprite? Thanks!

2
Quote
I hope you're using one texture with all the images on it and use the texture rect to extract the wanted section.

I will admit I was originally loading in all .PNG's into a vector of sf::Texture, which I know now was not a good idea. I compiled all the pictures into 1 png in photoshop and then changed the dimensions like you said and it worked perfectly! I'm ashamed I didn't think of that earlier. Thank you though! This is a much nicer solution :)

3
Graphics / Differently sized sf::Texture's causing sprite to move
« on: May 18, 2018, 12:04:02 am »
Hello. I have a Sprite that is made up of ~20 different .png's that my Sprite cycles through to create a 'running' animation. My issue is that a couple of the images have a bigger height then the rest of them. This causes the Sprite to move down vertically an inch or two. I'm guessing this is because a Sprite's origin is always relative to it's top left position, thus causing the sprite to move down because the top left remains in the same spot.

I have sorta fixed this by creating a variable called count that keeps track of what frame of animation the Sprite currently holds, and if it is on one of the bigger images, I manually bump the sprite back up to make it look like it never bounced down. I feel like this is really hackish and that there is a much more elegant way to fix this. Any thoughts? The only reason I don't want to keep this way of fixing it is because I have a bunch of other player sprites I want to use in my game and they all will have this problem and manually bumping all of the sprites up seems tedious and unnecessary.

I've attached a small clip showing what happens with my sprite.

Pages: [1]
anything