Page 1 of 1

Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 1:06 pm
by dashark1
Is it possible to set the x and y possitions in each frame of an animation with seperate .png images

eg)

Code: Select all
image001.x = 0
image001.y = 1
image002.x = 2
image002.y = -1
image003.x = -2
image003.y = 5
...
etc

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 1:24 pm
by DarkParadox
For different frames in one animation:
Code: Select all
if(animpos = 0)//first frame
{
    x = 1;
    y = 1;
}
if(animpos = 1)//second frame
{
    x = 2;
    y = 2;
}

for different animations:
Code: Select all
if(animindex = 0)//first image
{
    x = 1;
    y = 1;
}
if(animindex = 1)//second image
{
    x = 2;
    y = 2;
}

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 1:48 pm
by dashark1
It doesnt work, I am using this code:

Code: Select all
if(charanim == 0) // alert
{
    ChangeAnimation("Event Actor", "alert.body1", NO_CHANGE);
    if(animpos == 0)
    {
        x = -3;
        y = -18;
    }
    if(animpos == 1)
    {
        x = -3;
        y = -19;
    }
    if(animpos == 2)
    {
        x = -3;
        y = -20;
    }
    if(animpos == 3)
    {
        x = -3;
        y = -19;
    }
}



it still shows the actor in random places.

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 2:12 pm
by DarkParadox
where did you put that code?
(draw actor, collision, etc.)

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 2:14 pm
by dashark1
in draw actor

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 2:15 pm
by DarkParadox
ChangeAnimation should not go in draw actor

P.S.
click the Chat button at the top of the page.

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 2:17 pm
by dashark1
right ... but it still doesnt work, it's in draw actor and now this is my code

Code: Select all
if(charanim == 0) // alert
{
    if(animpos == 0)
    {
        x = -3;
        y = -18;
    }
    if(animpos == 1)
    {
        x = -3;
        y = -19;
    }
    if(animpos == 2)
    {
        x = -3;
        y = -20;
    }
    if(animpos == 3)
    {
        x = -3;
        y = -19;
    }
}



I dont know how to fix this .. o.O

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sat Oct 04, 2008 2:19 pm
by DarkParadox
define what it does.

(CLICK THE CHAT BUTTON!!!!)

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sun Oct 05, 2008 2:00 am
by DilloDude
If you have a lot of ifs like that where only one should happen, use else ifs. I=Also, in that case, all are checking the same value, and they're all == comparisons, so you can use a switch instead.

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sun Oct 05, 2008 2:27 am
by dashark1
Ok, I forgot how to do switches ...

Code: Select all
if(playeranim == 0) // stand
{
    switch(animpos)
    {
        case 0:
            x = 16;
            y = 31;
        case 1:
            x = 17;
            y = 31;
        case 2:
            x = 18;
            y = 31;
        case 3:
            x = 17;
            y = 31;
    }
}

but isn't that right?

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sun Oct 05, 2008 7:02 am
by DilloDude
For this situation, you need to use a break after each case:
Code: Select all
...
switch(animpos)
{
    case 0:
    x = 16;
    y = 31;
    break;

    case 1:
    x = 17;
    y = 31;
    break;
etc...

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sun Oct 05, 2008 8:52 am
by dashark1
now I get "switch expression is not intergal" ... also with using if and else if it goes to the frame then waits for half a second then it goes to the proper x and y.

Re: Is it possible to set the x and y positions of each frame

PostPosted: Sun Oct 05, 2008 9:09 am
by DilloDude
Oh, yeah. I think animpos is actually a real number. Make sure to use (int)animpos in the switch statement.