How to make other objects appear/disappear.

Started by Herooftime1000, Mon 27/10/2008 04:21:07

Previous topic - Next topic

Herooftime1000

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.

Trent R

#1
Try the .Visible property for objects, and the .x and .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 for characters.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Herooftime1000

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?

monkey0506

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.

Trent R

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.
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

I did this using an Overlay:
Code: ags
        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.

Herooftime1000

Quote from: KhrisMUC on Mon 27/10/2008 09:48:33
I did this using an Overlay:
Code: ags
        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!

Herooftime1000

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?

Khris

(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:

Code: ags
  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
  }


SMF spam blocked by CleanTalk