Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Herooftime1000 on Mon 27/10/2008 04:21:07

Title: How to make other objects appear/disappear.
Post by: Herooftime1000 on Mon 27/10/2008 04:21:07
I want to make an object/character/item appear in one point of the room, move it to another destination, and then disappear once it reaches it's destination. Please help.
Title: Re: How to make other objects appear/disappear.
Post by: Trent R on Mon 27/10/2008 05:20:39
Try the .Visible (http://www.americangirlscouts.org/agswiki/Object_functions_and_properties#Object.Visible) property for objects, and the .x (http://www.americangirlscouts.org/agswiki/Character_functions_and_properties#Character.x) and .y (http://www.americangirlscouts.org/agswiki/Character_functions_and_properties#Character.y) properties for characters. Read them in the manual for more information on them. (I've linked the online manual entries in this post too)
[Edit]:You could also try the .Transparency (http://www.americangirlscouts.org/agswiki/Character_functions_and_properties#Character.Transparency) for characters.


~Trent
Title: Re: How to make other objects appear/disappear.
Post by: Herooftime1000 on Mon 27/10/2008 06:00:03
Ok, ok. But let's say that I want my character to throw a rock. After my use the rock inventory item and character makes a throw animation, how can I make the rock appear and should it be a character or an item?
Title: Re: How to make other objects appear/disappear.
Post by: monkey0506 on Mon 27/10/2008 06:25:51
To make the rock appear in the room you should use a Character or an Object. The difference is that the Character can appear in any room, the Object could only appear in rooms you create it in.
Title: Re: How to make other objects appear/disappear.
Post by: Trent R on Mon 27/10/2008 08:19:54
In that case, check out the IsCollidingWithChar and IsCollidingWithObject functions to check when the rock hits a specified character or object.


~Trent
PS-I'm usually more helpful than this, so I apologize due to my brain being fried.
Title: Re: How to make other objects appear/disappear.
Post by: Khris on Mon 27/10/2008 09:48:33
I did this using an Overlay:
        Overlay*o=Overlay.CreateGraphical(320, 0, 381, false);
        int x=301;
        int y;
        while(x>=159) {
          y=35+((x-240)*(x-240)/64);
          o=Overlay.CreateGraphical(x, y, 381, false);
          Wait(1);
          x-=2;
        }
        player.Walk(173, 148, eBlock);
        Wait(10);
        PlaySound(4);
        o.Remove();

You move it by recreating it at another position, and in the end call .Remove() to make it disappear.
Title: Re: How to make other objects appear/disappear.
Post by: Herooftime1000 on Mon 27/10/2008 15:49:03
Quote from: KhrisMUC on Mon 27/10/2008 09:48:33
I did this using an Overlay:
        Overlay*o=Overlay.CreateGraphical(320, 0, 381, false);
        int x=301;
        int y;
        while(x>=159) {
          y=35+((x-240)*(x-240)/64);
          o=Overlay.CreateGraphical(x, y, 381, false);
          Wait(1);
          x-=2;
        }
        player.Walk(173, 148, eBlock);
        Wait(10);
        PlaySound(4);
        o.Remove();

You move it by recreating it at another position, and in the end call .Remove() to make it disappear.

Ah, this explains everything! Thanks!
Title: Re: How to make other objects appear/disappear.
Post by: Herooftime1000 on Mon 27/10/2008 17:17:06
Oh oh...New problem...

Overlay*Rock=Overlay.CreateGraphical(200, 145, 45, true);

Wait(5);

Rock.X=121;

Rock.Y=126;

Wait(10);

It seems when I make this command it shows in one place then quickly the other. How can I make it so that it moves smoothly to it's destination?
Title: Re: How to make other objects appear/disappear.
Post by: Khris on Mon 27/10/2008 17:35:48
(Don't quote the complete previous post.)

Look at the while loop I've posted. X is decremented by 2 every iteration, until it's no longer >=159.

If you want to move the rock from 200,145 to 121,126, do this:

  Overlay*Rock=Overlay.CreateGraphical(200, 145, 45, false);
  int x=200;
  int y;
  while(x>=122) {
    y=145-((200-x)/4);
    o=Overlay.CreateGraphical(x, y, 45, false);
    Wait(1);
    x-=2;     // change this to change the movement speed
  }
Title: Re: How to make other objects appear/disappear.
Post by: Herooftime1000 on Mon 27/10/2008 17:52:57
Thanks and sorry...