Cant figure out the mistake..

Started by , Tue 11/02/2014 13:28:06

Previous topic - Next topic

Thesie


Hi all!

Im trying to put this into my game

Code: ags

173     if   (cGooli.ChangeView == VGOOLINORMAL) { 
174     cGooli.LockView(VGOOLIHEADUP);
175     cGooli.Animate(0, 8, eOnce, eNoBlock, eForwards);
176     Wait (40);
177     cGooli.UnlockView();
178     }


-> means that if the character changes the view to normal, first he play the "head up" view.. maybe there is a general mistake in the script, but ags tells me

Error (Line 173): '(' expected


And I dont understand because THERE IS a '(' :grin:

Maybe someone has an idea?

Thank you!!!

DoorKnobHandle

ChangeView is a method (function) that causes a character (cGooli in your case) to change its view. What you need is the attribute (variable) in order to compare it to VGOOLINORMAL. The attribute is simply called cGooli.View.

Thesie


Alright, I guess I am still in the very beginning :undecided:

So I make a new global variable, give it the name gooli.view, and then it will be which type and which value?

I have to admit I feel lost now :grin:

DoorKnobHandle

You can just do the comparison like this (line 173):

Code: ags
if   (cGooli.View == VGOOLINORMAL) {

Thesie


Oh gosh... Thank you!!!:sealed:

Thesie


Now I can start my game, but unfortunatley now the effect I wanted is gone, cause the character doesnt move at all anymore..

I just want the character to make a animation between eating and walking, so between the change of views.. now its not doing anything right
anymore.. maybe because I put it into the repeatedly execute?

DoorKnobHandle

So VGOOLINORMAL is the normal walking view I guess? And VGOOLIHEADUP the transition animation view? And there's also something like a VGOOLIEATING view as well?

First of all, I would advice against using a new view for every animation, you can just use one view for your character and then have the first loops in that view be the walking animations (4 or 8 depending on if you have diagonal movement or not) and then make the eating animation the loop underneath those and the transition from eating to walking the loop underneath again. Then you can simply call cGooli.Animate to run a blocking animation.

Thesie


ok, so the character is an animal.

it has a walking view (normal), an idle view (eating), and a talking view (talking^^)

the character is walking around to three or four different positions set by a random timer. so everytime before it starts walking there, it should lift its head, and before it goes idle again, put the head down, because the idle view is with the head down. and of course, if you want to talk to it, it should lift the head and backwards..

so I have it like this now:

Code: =ags
if   (cGooli.View == VGOOLINORMAL) { 
      cGooli.LockView(VGOOLIHEADUP);
      cGooli.Animate(0, 8, eOnce, eNoBlock, eForwards);
      cGooli.UnlockView();
    }
    
    else if (cGooli.View == VGOOLITALK) {
      cGooli.LockView(VGOOLIHEADUP);
      cGooli.Animate(0, 8, eOnce, eNoBlock, eForwards);
      cGooli.UnlockView();
      
    }
    else if (cGooli.View == VGOOLIIDLE) {
      cGooli.LockView (VGOOLIHEADUP);
      cGooli.Animate(0, 8, eOnce, eNoBlock, eBackwards);
      cGooli.UnlockView();
    } 


I put the script into every room, in the room_repexec.. so the game runs again. but its not really a difference, maybe the animation is to short.. you just see the character eating and walking, no headmovement..

to put the animation into one view is a good idea, but still the animation has 4 loops, depending on how the character is standing.. thats something i also didnt figure out yet.. e.g. when the character is looking to the right, it should obviously also use the animation for right head lifting..


DoorKnobHandle

Ah okay well that changes things a little bit. In this case, you may use separate views to simplify things a bit. What you could do is have the timer play the head up animation instead of moving the character immediately. Then in repeatedly_execute you can check if you've reached the end of the head up animation (use cGoolie.View and cGooli.Frame to find out if you're at the last frame) and only then start the walking.

Also, don't put this code in multiple places. If this animal character stays in one room, only put the code into that room. If it moves between rooms, the global script would be a good place.

Ghost

Code: ags
[code = ags]
cGooli.LockView(VGOOLIHEADUP);
cGooli.Animate(0, 8, eOnce, eNoBlock, eForwards);
cGooli.UnlockView();


This. You are calling the animation as non-blocking. That means the next command is instantly executed. So you change the view, but even before the animation can start you release it. Change eNoBlock to eBlock, that should do the trick.

Thesie



Quote from: DoorKnobHandle on Tue 11/02/2014 14:30:46
What you could do is have the timer play the head up animation instead of moving the character immediately.

yes I did that, looks like this

Code: =ags
 if (IsTimerExpired(2)&& GooliBleibt) {
          i = Random (2);
              if (i==0) {
              cGooli.LockView(VGOOLIHEADUP);
               cGooli.Animate(0, 5, eOnce, eBlock, eForwards);
               cGooli.UnlockView();
              cGooli.Walk(194, 194, eBlock, eWalkableAreas);
               cGooli.LockView(VGOOLIHEADUP);
               cGooli.Animate(0, 5, eOnce, eBlock, eBackwards);
               cGooli.UnlockView();
              }
              else if (i==1) {
               cGooli.LockView(VGOOLIHEADUP);
               cGooli.Animate(0, 5, eOnce, eBlock, eForwards);
               cGooli.UnlockView();
              cGooli.Walk(73, 160, eBlock, eWalkableAreas);
               cGooli.LockView(VGOOLIHEADUP);
               cGooli.Animate(0, 5, eOnce, eBlock, eBackwards);
               cGooli.UnlockView();
                            }
              else if (i==2) {
              cGooli.LockView(VGOOLIHEADUP);
              cGooli.Animate(0, 5, eOnce, eBlock, eForwards);
              cGooli.UnlockView();
              cGooli.Walk(140, 102, eBlock, eWalkableAreas);
              cGooli.LockView(VGOOLIHEADUP);
              cGooli.Animate(0, 5, eOnce, eBlock, eBackwards);
              cGooli.UnlockView();
              
              }
          SetTimer(2, 400); 


but you dont really see the movement, plus the character now walks sooooo slowly, and you cant stop it >.< but I put the animation in front of all the talking, so that works now!!

Quote from: DoorKnobHandle on Tue 11/02/2014 14:30:46
Also, don't put this code in multiple places. If this animal character stays in one room, only put the code into that room. If it moves between rooms, the global script would be a good place.

Ok maybe its just to complicate how I imagined it.. so the character is trapped in the timer UNTIL I do something, from that point on it follows me to every room.. and thats why I put it into all rooms.

Quote from: Ghost on Tue 11/02/2014 14:51:55
You are calling the animation as non-blocking. That means the next command is instantly executed. So you change the view, but even before the animation can start you release it. Change eNoBlock to eBlock, that should do the trick.

thank you, I already changed that, but as i wrote nothing is really happening despite the fact that the character moves as slow as a snail now :sad:

SMF spam blocked by CleanTalk