Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


riku743

Member Since 22 Mar 2013
Offline Last Active Mar 23 2013 01:05 PM

Posts I've Made

In Topic: DirectX: Unable to Flip Sprite Horizontally

22 March 2013 - 06:05 PM

Aha! I had tried using D3DXMatrixTransformation2D before, but I was using it only for the scaling, not for the position as well. It apparently works better if you do it all at once. Also, now that it's doing it this way, setting the center to the actual center doesn't mess things up.

 

....However, although the sprite is now visible, it has somehow done both a horizontal flip and a vertical flip, and has moved up . Or, more accurately, a 180 degree rotation. Here's what the adjusted code snippet looks like:

	D3DXVECTOR2 vCenter( s_sprite.width/2.0f, s_sprite.height/2.0f );
	D3DXVECTOR2 vPosition( s_sprite.xPosit, s_sprite.yPosit );
	D3DXVECTOR2 vScale(1.0f, 1.0f);
	D3DXMATRIX transMatrix;
																			
	s_sprite.lpSprite->Begin( D3DXSPRITE_ALPHABLEND );

	if(s_sprite.flipHoriz)
		vScale.x = -1.0f;
	
	D3DXMatrixTransformation2D(&transMatrix, &vCenter, 0.0f, &vScale, NULL, 0.0f, &vPosition);

	s_sprite.lpSprite->SetTransform(&transMatrix);

    s_sprite.lpSprite->Draw( t_texture.lpTexture,
                          &srcRect,
                          NULL,
                          NULL,
                          D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );

 

It's possible I'm just using D3DXMatrixTransformation2D incorrectly. Before I changed the center to the real center, it was as if it flipped horizontally, and then reflected vertically over the top line bounding the sprite rectangle. Now it stays in the same place, it's just upside-down.

 

Edit: Nevermind! I had it making the y value of the scaling vector negative, when it seems it should have been the x value in this case.

Thanks for the help, guys.


In Topic: nill

22 March 2013 - 04:56 PM

noone is using the sound or input features of the SDK

Out of curiosity, why not?


In Topic: DirectX: Unable to Flip Sprite Horizontally

22 March 2013 - 04:26 PM

Nope. The position is as it should be, everything from all measures I can think of appears to be normal. I can even still move it around as usual. It's just not visible. 


In Topic: DirectX: Unable to Flip Sprite Horizontally

22 March 2013 - 03:49 PM

I'm not back face culling -- my game is completely 2D, so I assumed I didn't need to. I tried setting the cull mode to none, and it didn't change anything.

 

If you mean the UVs for the texture, I don't actually set those. I create the texture using D3DXCreateTextureFromFileEx and loadTexture(), and then Sprite->Draw() to associate it with the sprite. I don't ever draw textures directly or onto anything but sprites, so as far as I know it wasn't necessary to do anything else (and it worked fine up until this point). If you mean something else, could you elaborate?

 

I'm pretty new to this, apologies if I don't understand or am doing things in a non-standard way.


PARTNERS