gui not working right

Started by Icey, Thu 27/01/2011 21:53:30

Previous topic - Next topic

Icey

I have a gui & its img acts like a key or a switch in the game. know at a point in the game the player must walk on a region that start the players to talk then they move to a certain spot.
Code: ags
//
if (player1.NormalGraphic == 10){
  Dave.Walk(825, 264, eBlock, eAnywhere);
  
}
 if (player1.NormalGraphic == 45){
  chris.Walk(825, 264, eBlock, eAnywhere);
  
}
 if (player1.NormalGraphic == 63){
  muffy.Walk(825, 264, eBlock, eAnywhere);
  
}
  if (player1.NormalGraphic == 73){
  tifa.Walk(825, 264, eBlock, eAnywhere);
  
}
 //team mate
 
 if (player2.NormalGraphic == 10){
  Dave.Walk(876, 302, eBlock, eAnywhere);  
} 
  if (player2.NormalGraphic == 45){
  chris.Walk(876, 302, eBlock, eAnywhere);
  
} 


  if (player2.NormalGraphic == 63){
  muffy.Walk(876, 302, eBlock, eAnywhere);
  
} 
  if (player2.NormalGraphic == 73){
  tifa.Walk(876, 302, eBlock, eAnywhere);
  
} 
//play commence sounds
Display("commence!");

//battle gui fade in

  }


The problem is is that the [team mate] section works but it seems to set muffy as the the selected team mate but tifa was set as the team mate before the battle.

Khris

We can't really help you much with this. The code has no obvious error, I'd double check the slot numbers and try different combinations to see which ones fail.

Icey


Icey

BTW I dont know how to work slots and stuff. I found it in the Manuel(ddq) but I just dont know how to work it.

Icey

NVM you just have to set the team mate before hand.

Khris

A slot number is simply the sprite's number from the Sprite manager.

Icey

ok. Also I had the commands for the team mates mixed up. It checked for tifa's pic and it told muffy to walk & the same goes for tifa. :)

monkey0506

You might be less likely to confuse yourself like that if you'd use more descriptive names like cTifa and cMuffy instead of player1 and player2.

You can always use the player keyword as a direct reference to the current player:

Code: ags
player.Walk(x, y); // and such


And if you need to check it then you do it just like you normally would any other value:

Code: ags
if (player == cTifa) { } // do something here?

Icey

I see.

But player 1 & player 2 are just names for buttons in a gui. player1 stands for leader and player 2 stands for ally.

monkey0506

Duh..If I'd looked at your code for more than 1/2 of a nanosecond I might have realized that. I just saw the names of player1 and player2 and was wondering why you'd call them that.

For Button controls it's common convention to use a prefix like btn (i.e., btnTifa, btnMuffy). Some users prefer to use a single character prefix (like bTifa and bMuffy) instead, but that creates ambiguity in various cases (like between Labels and ListBoxes, or InventoryItems and InvWindows).

It's ultimately a matter of personal preference, but as I said in my previous post (albeit completely brain dead when it came to recognizing what actual type you were using..O_o), using more descriptive script names can help you out in finding logical errors in your code.

Icey

I am saying I understand you.

But P1 & p2 are just buttons it's what's on them that counts in the game. there are not four buttons pacifically for tifa,muffy,chris, & dave. There is only two of the CATB(cross assault time battle)

SMF spam blocked by CleanTalk