Jump to content

  • Log In with Google      Sign In   
  • Create Account


chris2307

Member Since 24 Apr 2012
Offline Last Active Mar 08 2013 09:06 AM

Posts I've Made

In Topic: Sprite object no longer renders when put in to a Vector

05 February 2013 - 11:11 AM

Anyone?


In Topic: Sprite object no longer renders when put in to a Vector

03 February 2013 - 04:27 PM

Should probably mention that I have a headers file:
#ifndef HEADERS_H
#define HEADERS_H

#define KEY_DOWN(vk_code)((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)

#include <windows.h>
#include <windowsx.h>
#include <vector>
#include <d3d9.h>
#include <d3dx9.h>
#include <string>
#include <fstream>
#include <iostream>
#include <string>
#include <ctime>
#include <sstream>
#include <cmath>


#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

#define SCREEN_WIDTH  1024 
#define SCREEN_HEIGHT 768

LPDIRECT3D9 d3d;                 // Pointer to Direct3D interface
LPDIRECT3DDEVICE9 d3dDevice;     // Pointer to the device class
LPD3DXSPRITE d3dSprite;          // Pointer to Direct3D Sprite interface

std::ofstream diagFile;

#endif

In Topic: Struggling to change render order of lists of objects (XNA)

25 January 2013 - 01:52 PM

Thanks for the reply.

 

The problem with putting the objects in the same list is that they are two completely different objects with very different behaviors. For example, I am trying to hit the zombie with the truck but avoid the road debris, the zombie moves around and is animated where are the debris is static so I need separate lists for the zombie object and debris object. Otherwise, I would have have indeed used a Z or depth value as you suggested.

 

Also, the Zombie is taller than the debris objects but... I am returning the Y pos, not the size of the sprite. I also have an origin set up for each of the sprites which is the sprite texture height so at the bottom. So the Y position should relate to the very bottom of each sprite.


In Topic: Sprite fails to draw when calling my draw() method

10 January 2013 - 02:39 PM

I figured it! And rather obvious when you think about it too.

 

I used a switch statement as you suggested and found that I was getting a D3DERR_INVALIDCALL. Went back and looked at the way in which I was initialising my parameters. Soon realised I was creating my sprite object before I ran my initDirectX method. So, in turn I wasn't actually loading any textures or positions in the first place when I thought I was.

 

Anyway, thanks for the help. Took a while but finally got there!


In Topic: Sprite fails to draw when calling my draw() method

10 January 2013 - 11:48 AM

Hi, thanks for the reply.

 

I have checkted and the draw call is definitely failing and the return code I am getting is 1 (I have not been able to find a way of telling whether it is a D3DERR_INVALIDCALL or D3DXERR_INVALIDDATA error.

 

One thing I did think, when drawing a sprite to the screen, we must put the call to the draw() method in between:

 

</p><pre>
d3dSprite->Begin(D3DXSPRITE_ALPHABLEND);</pre>
// ...
 
<pre>
d3dSprite->End();</pre>

 

Am I correct in thinking I can just put the call to the objects draw method in between these two and it will still work?


PARTNERS