1
DotNet / Re: Merging sprite's position with the position of the owning class?
« on: June 06, 2015, 01:10:25 pm »
I got you there. I thought there would be a other way around. So i can assign the render states Transform to the sprite.
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.
I believe I figured out what's happening here. You are setting your sprites' position twice. You already set the position of your sprites on update. Then on Draw, you apply entity's current transform (position) into renderstates. SFML.Graphics.Sprite is a Transformable too so you are actually drawing sprite into entity's position + sprite's position. Result is that the sprites position property doesn't represent what you see on screen, it's real position is actually to the left but it's drawn more to the right.
If you comment states states.Transform *= this.Transform; it works. But I'd suggest you to implement your own GetGlobalBounds for entities/physicsobjects instead. Chances are you're gonna need a different bounding box from the sprite anyway (ie. sprite is not cropped or has empty space around it) so I think it'd be a good idea to do that first. Separating things like this from sprites and drawing is a good idea anyway imo.
Quotethe intersecting of player1 and player2 is mathmatically right - but the displayed sprite of player2 kinda doesn't look right, because player1 isn't hitting it really. I already checked the bounds and positions of player2 and its sprite - can't find a solution.Is that a different problem?
Odd if I wanted to make a sprite within a sprite I'd just set the sprite that should be in the same place as the other to its position directly. Or if a follow sprite make its vector aim toward it.
Basically it would be like this for sprite within sprite> Sprite A Pos = Sprite B Pos
As for what's wrong with transform I got no clue. Maybe the original position of the sprite isn't changing.
And what would make the sprite magically follow its owner entity? The usual solution to this problem is to apply the Player's transform to the RenderStates in the DrawCurrent function. See the C++ tutorials for more details.