~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
Creating Animated Objects in Danmakufu
(1/1)
Hat:
Doesn't even have to be an animated object, I just need to be able to make a certain graphic, animated, in a certain part of the screen (where I can set the image parameters with SetGraphicRect). Insofar, every time I tried this, no matter what the SetGraphicRect would apply itself to the boss's image and image location, not the place I specified. This caused, instead of a simple animation appearing in the center of the screen (purely for testing purposes), the boss's graphic would start drawing on the SetGraphicRects I used, and vibrated brilliantly... but pointlessly.

I'm not entirely sure how to get an object to do this, because there doesn't seem to be any setgraphicrect function for effect objects, or anything else.

EDIT: Okay, I have been mildly disgusted. Do I have to call effect objects, and just keep changing the positions of the vertices over and over and over again? -_- I'm making this for a player character, btw, in case you didn't know.
Stuffman:
To get an object to animate you've got two options:
a) Use SetTexture repeatedly and have each frame be a different image
b) Use SetVertexUV to map the vertexes to different parts of the same image

I would need to see your code to understand what's wrong with it.
Hat:
This is the most recent copy I have... it's very beaten-up from fiddling around.

--- Code: ---#TouhouDanmakufu
#Title[Yuka Animation Task Testing]
#Text[Seeing if I can outsource animation loops to tasks, and use yield in them.]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
    let Image = "script\img\testanimationimage.bmp";
    let frame = -120;
    TAnimation;

    @Initialize {
        SetLife(2000);
        SetTimer(50);
        SetScore(1000000);

        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(YOUMU, "Test Sign "\""Test"\", "", 0, 0, 0, 0);

        LoadGraphic(ImgBoss);
        LoadGraphic(Image);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        yield;
        DrawGraphic(GetCenterX, GetCenterY);
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
        DeleteGraphic(Image);
    }
task TAnimation {
    SetTexture(Image);
    loop{
    SetGraphicRect(0, 0, 100, 100);
    yield;
    SetGraphicRect(100, 0, 200, 100);
    yield;
    SetGraphicRect(0, 100, 100, 200);
    yield;
    SetGraphicRect(100, 100, 200, 200);
    yield;
    }
    }
}
--- End code ---
I just have a test image that I use for it. It goes 1, 2, 3, 4 really fast (but I'd be able to get the picture, I think).
Stuffman:
It looks like you're trying to do something more complicated than you need to; you can keep pretty much all of this in the DrawLoop.

Try this:


--- Code: ---script_enemy_main
  let ImgBoss="script\img\ExRumia.png";
  let Image="script\img\testanimationimage.bmp";
  let frame=0;
  @Initialize{
    SetLife(2000);
    SetTimer(50);
    SetScore(1000000);
    SetMovePosition02(GetCenterX,GetClipMinY+120,120);
    CutIn(YOUMU, "Test Sign "\""Test"\", "", 0, 0, 0, 0);
    LoadGraphic(ImgBoss);
    LoadGraphic(Image);
  }
  @MainLoop{
    frame++;
    yield;
  }
  @Finalize{
    DeleteGraphic(ImgBoss);
    DeleteGraphic(Image);
  }
  @DrawLoop{
    SetTexture(ImgBoss);
    SetGraphicRect(can't remember Rumia's dimensions offhand);
    DrawGraphic(GetX,GetY);
    SetTexture(Image);
    if(frame%60<15){
      SetGraphicRect(0, 0, 100, 100);
    }else if(frame%60>=15 && frame%60<30){
      SetGraphicRect(100, 0, 200, 100);
    }else if(frame%60>=30 && frame%60<45){
      SetGraphicRect(0, 100, 100, 200);
    }else if(frame%60>=45){
      SetGraphicRect(100, 100, 200, 200);
    }
    DrawGraphic(GetCenterX,GetCenterY);
  }
}
--- End code ---

If you're not familiar with modulus (which is what that % is) it divides a number and gives you the remainder. So 24%10 would be 4. So what this does is divide the image animating loop into 60 frames, with one part every 15 frames.
Hat:
I am familiar with modulus. Hmmm... okay, I can see where I went wrong. I just didn't understand the syntax of using draw functions (I wish that the draw functions could refer to individual loaded graphics like bullet scripts do; that would make my life infinitely easier)
Navigation
Message Index

Go to full version