Page 1 of 1

strange thing! (animpos problem)

PostPosted: Sat Apr 09, 2011 8:03 pm
by sonicfire
hi fellas!

so i have this actor on screen with 50 animation frames, starting at zero, stopped, called
"energyTopLeft" and in Create Actor Event i have:
Code: Select all
ChangeAnimationDirection("Event Actor", STOPPED);
animpos=0;


Fine. Now, in a function i do this:
Code: Select all
switch(collide.whichOne)
        {
            case 0: playSound(1); energyTopLeft.animpos++; break;
        }


which works somehow!
The sound (from my other function) is played.
BUT: the animpos won´t change at all, it stays at zero.

So my question is: What am i doing wrong here? Or is this a bug?

Thanks for any help or ideas :)

Re: strange thing! (animpos problem)

PostPosted: Sat Apr 09, 2011 9:24 pm
by lcl
Where is that code located?
In some collision event?
Is whichOne an actor variable?

Answer those questions so I can help you. :)

Re: strange thing! (animpos problem)

PostPosted: Sat Apr 09, 2011 10:48 pm
by skydereign
If it is in a function, I assume you mean global code, and that is your problem. Using actorName.actorVar is messed up in global code. You can access the event actor's variables, but if you want to use any others you have to add a comment with the actor's name in the event. This is a really undesirable fix... but it is the best we have.
Global Code -> function
Code: Select all
void
darkenMenu ()
{
    menu.r=100;
    menu.g=100;
    menu.b=100;
}


If you want that to work when you call it, do this.
Code: Select all
// menu
darkenMenu();


Now if you have multiple actors with vars being set, you can put in more names in the comment before the function call. It is really annoying problem, and the fix makes no sense since comments are supposed to be ignored, but that should fix your problem.

Re: strange thing! (animpos problem)

PostPosted: Sun Apr 10, 2011 7:45 am
by sonicfire
@lcl: Thanks, global code! its a function. and "whichOne" is an actor variable!

@skydereign: Thanks! no THAT is weird! :shock: i have to add a comment with the actor´s name i wanna modify?
tried this, still no luck (global code function) :(
Code: Select all
switch(collide.whichOne)
        {
            case 0:
            // energyTopLeft
            changeEnergyTL();
            break;
        }


and the function:
Code: Select all
void changeEnergyTL ()
{
    energyTopLeft.animpos++;
}


Could it be a problem because i´m running a function from within a function somehow?

Re: strange thing! (animpos problem)

PostPosted: Sun Apr 10, 2011 7:59 am
by sonicfire
i´ve now simply used another method, via the Event Actor variables :)

Code: Select all
switch(collide.whichOne)
        {
            case 0:
            collide.doEnergy=1;
            break;
        }


and in my energyTopLeft actor´s draw Event:
Code: Select all
if (doEnergy)
{
    doEnergy=0;
    animpos++;
}

Re: strange thing! (animpos problem)

PostPosted: Sun Apr 10, 2011 8:46 am
by skydereign
The comment has to go in the event code. Comments before functions within functions still need the comment in the event (not global code). Here's an example.
Global Code
Code: Select all
void
funcA ()
{
    actor.r=0;
    actor.g=0;
    actor.b=0;
}

void
funcB ()
{
    funcA();
}


player -> KeyDown (space) -> Script Editor
Code: Select all
// actor
funcB();


Notice the comment is in the event code and not the global code.

Re: strange thing! (animpos problem)

PostPosted: Tue Apr 12, 2011 1:32 pm
by sonicfire
ahhh! thanks very much! :)