strange thing! (animpos problem)

Non-platform specific questions.

strange thing! (animpos problem)

Postby sonicfire » Sat Apr 09, 2011 8:03 pm

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 :)
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: strange thing! (animpos problem)

Postby lcl » Sat Apr 09, 2011 9:24 pm

Where is that code located?
In some collision event?
Is whichOne an actor variable?

Answer those questions so I can help you. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: strange thing! (animpos problem)

Postby skydereign » Sat Apr 09, 2011 10:48 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: strange thing! (animpos problem)

Postby sonicfire » Sun Apr 10, 2011 7:45 am

@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?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: strange thing! (animpos problem)

Postby sonicfire » Sun Apr 10, 2011 7:59 am

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++;
}
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: strange thing! (animpos problem)

Postby skydereign » Sun Apr 10, 2011 8:46 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: strange thing! (animpos problem)

Postby sonicfire » Tue Apr 12, 2011 1:32 pm

ahhh! thanks very much! :)
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest