
like this pic.how to trans the color(255,0,255)?
and how to get a source x,y to the texture2d?
make the pic is 5*5
class AnimTexBase extends Actor;
var Texture AnimTexture; //AnimTexture
var float AnimWidth; //a animation width
var float AnimHeight; //a animation height
var float AnimDrawIndex; //play which group
var int AnimIndex; //play which animation
var float PlayDelay; //play delay time
var float MaxIndex; //max animation numbers;
//Start
simulated event PostBeginPlay()
{
super.PostBeginPlay();
}
//draw Anim
simulated function DrawAnimTex(vector2D Pos,Canvas c)
{
local float sourceX,sourceY;
c.SetDrawColor(255, 255, 255);
//set pos
c.SetPos(Pos.X, Pos.Y);
//get Texture source
sourceX = AnimIndex * AnimWidth;
sourceY = AnimDrawIndex * AnimHeight;
//draw it.
c.DrawTile(AnimTexture, AnimWidth, AnimHeight, sourceX, sourceY, AnimWidth, AnimHeight);
return;
}
//change play AnimIndex
simulated function ChangeDrawIndex(float mouseIndex)
{
AnimDrawIndex = mouseIndex; //set play which group
AnimIndex = 0; //again head.
}
//start timer to change AnimIndex
simulated function StartDraw()
{
if(!IsTimerActive(nameof(ChangeAnimImage)))
{
SetTimer(PlayDelay, true, nameof(ChangeAnimImage));
}
}
//stop timer to change AnimIndex
simulated function StopDraw()
{
if(IsTimerActive(nameof(ChangeAnimImage)))
{
ClearTimer(nameof(ChangeAnimImage));
}
}
//Timer
function ChangeAnimImage()
{
AnimIndex++;
if(AnimIndex == MaxIndex) AnimIndex = 0;
}
DefaultProperties
{
AnimWidth = 26
AnimHeight = 26
AnimDrawIndex = 1
AnimIndex = 0
PlayDelay = 0.1
MaxIndex = 5
AnimTexture=Texture2D'Effect.UI.Mouse0001tex'
}
Comment