Results 1 to 3 of 3

Thread: DirectX DrawPrimitive sprite move

  1. #1

    DirectX DrawPrimitive sprite move

    Hello

    I'm trying move a sprite using custom vertex using D3DFVF_XYZRHW.

    my code work to move sprite only when i set the position in OnCreate of my window...

    dont have a way to move it in runtime?

    this code dont work to change the position x ate runtime:

    Code:
     if key=VK_RIGHT then
      begin
      PosX := PosX + 1;
      end;
    
      if key=VK_LEFT then
      begin
      PosX := PosX - 1;
      end;
    
     { if FAILED(
        pVB.Lock(0, SizeOf(Vertices), pVertices, 0)) then
      Exit;
    
      CopyMemory(pVertices, @Vertices, SizeOf(Vertices));
      pVB.Unlock;
    my complete code is here:

    http://www.lordzero.co.nr/tmp/DrawPrimitive.zip

    suggestions are welcome.

    Greets
    Knowledge is power.

  2. #2

    DirectX DrawPrimitive sprite move

    You just need to move the array filling code:
    Code:
    Vertices[0].X := -Scale + PosX;
    ...
    to FormKeyDown.

  3. #3

    DirectX DrawPrimitive sprite move

    Quote Originally Posted by Mirage
    You just need to move the array filling code:
    Code:
    Vertices[0].X := -Scale + PosX;
    ...
    to FormKeyDown.

    yes guy.. thanks its working...

    but after the code to move i put this code to work:
    Code:
    if FAILED(
        pVB.Lock(0, SizeOf(Vertices), pVertices, 0)) then
      Exit;
    
      CopyMemory(pVertices, @Vertices, SizeOf(Vertices));
      pVB.Unlock;
    Knowledge is power.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •