Results 1 to 3 of 3
  1. #1
    dean-wingess's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Posts
    409
    Reputation
    29
    Thanks
    213
    My Mood
    Stressed

    Post [Snipped] Easiest Way to reset sprites

    Hello guys,
    i decided to show you a method to reset your sprites, because a lot of people were asking me how, but when i tried to help them they were like "wtf r u talkin 'bout??" yep, that's the most spread desease here, isn't it?

    It's very basic, easy and there are alot of ways.

    The way i like the best is this one:
    (Easy for beginners)

    First of all collect the names of your Textures you've created.
    [In order to do this you may need to use a drawtexture function, it makes no sense if it's loaded from bytes or file]
    In globals:
    Code:
    bool recreate = false;
    In Present or Endscene Put this (I recommended to make it easy to find for me -> above hacking stuff)
    Code:
    if(recreate){
    D3DXCreateTextureFromFileInMemory(pDevice, &_Page1, sizeof(_Page1), &Page1);// Your Texture. Do not Put a If Zero infront of the creation.
    // Do the stuff above with all your Textures!
    D3DXCreateSprite(pDevice, &SpriteMenu);// Your Sprite SpriteMenu = Your //LPD3DXSPRITE
    recreate = false;
    }
    After you finished doing this, add this into your Reset
    [Recommended you have a working reset in your Base|Source|C&P'ed thingy what ever.]
    For example:
    Code:
    HRESULT WINAPI hkReset(PREMETERS = Example){
    SpriteMenu->OnLostDevice();
    recreate =! recreate ;
    }
    // This is an example reset!
    This is the easiest method i could find.
    I tested it and it worked for me..
    Give me Feedback.
    Last edited by dean-wingess; 11-23-2010 at 09:08 AM.
    [YOUTUBE]e89lqiE0wi0[/YOUTUBE]

  2. The Following 2 Users Say Thank You to dean-wingess For This Useful Post:

    Drake (11-23-2010),hackkuchen (11-23-2010)

  3. #2
    Geecko's Avatar
    Join Date
    May 2009
    Gender
    male
    Posts
    112
    Reputation
    10
    Thanks
    360
    My Mood
    Goofy
    u can also store ur image in memory,i mean converting it in byte array and then load it...
    btw use to draw it use:

    Sprite->Begin(apply alphablend states here);
    Sprite->Draw(draw sprite);
    Sprite->End();

    in reset u have to release also ur texture and then re-create it,
    just do Texture->Release();

  4. #3
    dean-wingess's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Posts
    409
    Reputation
    29
    Thanks
    213
    My Mood
    Stressed
    Quote Originally Posted by Geecko View Post
    u can also store ur image in memory,i mean converting it in byte array and then load it...
    btw use to draw it use:

    Sprite->Begin(apply alphablend states here);
    Sprite->Draw(draw sprite);
    Sprite->End();

    in reset u have to release also ur texture and then re-create it,
    just do Texture->Release();

    yeah that could be easier xD
    [YOUTUBE]e89lqiE0wi0[/YOUTUBE]