After clicking a hotspot and an animation happens

Started by FalseHope, Mon 29/09/2008 09:03:47

Previous topic - Next topic

FalseHope

How do I make it so that when somebody clicks a hotspot (Maybe like in RPG game and a fireball comes out and fly towards the enemy when you click a fireball skil) and something moves? Please help me!

Creator

#1
Make a fireball object that's visible property is initially set to false.
Then when interacting with the hotspot:

Code: ags

function hEnemy_Interact()
{
  oFireball.SetPosition(x, y); // Set your own x and y coordinates.
  oFireball.Visible = true;
  oFireball.Move(x, y,  5, eBlock); // Set your own x and y coordinates.
  oFireball.Visible = false;
}


Or make a Fireball Inventory Item and then when using it on the hotspot:

Code: ags

function hEnemy_UseInv()
{
  if (player.ActiveInventory == iFireball) {
    oFireball.SetPosition(x, y); // Set your own x and y coordinates.
    oFireball.Visible = true;
    oFireball.Move(x, y, 5, eBlock); // Set your own x and y coordinates.
    oFireball.Visible = false;
  }
}


Did you even bother to search the forum or try to figure it out (by reading the manual perhaps)?

paolo

The above code won't work. The "int"s need to be removed. You give the type of a variable in the definition of a function, not when you call it.

If you want an animated fireball that moves across the screen, this can be done using a loop in which you change the position of the fireball a certain amount each time round the loop (and then probably pause for a fraction of a second, or else it will all happen too fast). This is basic scripting that you can find out more about in the AGS manual.

Creator

#3
Quote from: paolo on Mon 29/09/2008 17:26:58
The above code won't work. The "int"s need to be removed. You give the type of a variable in the definition of a function, not when you call it.

I know that. There's a comment after that line saying that FalseHope has to set his own x and y coordinates.

Quote from: Creator on Mon 29/09/2008 10:06:46
function hEnemy_Interact()
{
  oFireball.SetPosition(int x, int y); // Set your own x and y coordinates.
  oFireball.Visible = true;
  oFireball.Move(int x, int y,  5, eBlock); // Set your own x and y coordinates.
  oFireball.Visible = false;
}

I was just doing it the way the AGS Auto-Finish (or whatever it's called) does. It shows 'int x' and 'int y' when you go to type something in those areas. I'll change it anyway to make it less confusing.

SMF spam blocked by CleanTalk