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

Non-platform specific questions.

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

Postby dashark1 » Sat Oct 04, 2008 1:06 pm

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
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DarkParadox » Sat Oct 04, 2008 1:24 pm

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;
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby dashark1 » Sat Oct 04, 2008 1:48 pm

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.
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DarkParadox » Sat Oct 04, 2008 2:12 pm

where did you put that code?
(draw actor, collision, etc.)
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby dashark1 » Sat Oct 04, 2008 2:14 pm

in draw actor
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DarkParadox » Sat Oct 04, 2008 2:15 pm

ChangeAnimation should not go in draw actor

P.S.
click the Chat button at the top of the page.
Last edited by DarkParadox on Sat Oct 04, 2008 2:18 pm, edited 1 time in total.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby dashark1 » Sat Oct 04, 2008 2:17 pm

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
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DarkParadox » Sat Oct 04, 2008 2:19 pm

define what it does.

(CLICK THE CHAT BUTTON!!!!)
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby DilloDude » Sun Oct 05, 2008 2:00 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

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

Postby dashark1 » Sun Oct 05, 2008 2:27 am

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?
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DilloDude » Sun Oct 05, 2008 7:02 am

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...
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

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

Postby dashark1 » Sun Oct 05, 2008 8:52 am

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.
Image
dashark1
 
Posts: 11
Joined: Fri Sep 07, 2007 7:55 am
Score: 0 Give a positive score

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

Postby DilloDude » Sun Oct 05, 2008 9:09 am

Oh, yeah. I think animpos is actually a real number. Make sure to use (int)animpos in the switch statement.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron