Object visible at...

Started by Gepard, Fri 02/03/2007 16:07:55

Previous topic - Next topic

Gepard

I wantÃ,  to make an operation. I have a character (C) and an object (O) which is not initially visible. Now the character is WALKING. I want to do this: If I use inventory on C, the C will STOP (for example: x100, y251) and there will be a short animation and after that animation I want the object to be visible again, but on the same place where the character STOPPED. Can I do that?

Thanks in advance.
Drink up me 'arties! Yo ho!

Ashen

Have you tried? That's all pretty simple coding - you just need to stop the character moving and set the Object's postion to match character[C].x/y before you turn it on:
Code: ags

cC.StopMoving(); // Or whatever C's actual script-o-name is
object[0].SetPosition(cC.x, cC.y);
obejct[0].Visible = true;


Other things to consider:
- You might need an offset in the X value. Objects coords are taken from the bottom left corner, while characetr coords are the centre of the sprite. You may need to make it cC.x - (half object width) to make it look right.
- Since the Character Interactions are in the Global Script, you'll probably need to add a check that the player is in the right room when they use the item. (If this can only happen in one room - e.g. C doesn't change rooms - don't worry about this.) Also, remember that you can't you the Object's Script-o-name (oDoor, etc) in Global Script.

Please, make an effort to solve things yourself before posting - you could've figured this one out by just reading the manual. Even if it doesn't work, you can tell us what you tried and what the problems where.
I know what you're thinking ... Don't think that.

Gepard

I tried, but sorry anyway, never do that again, promise.
Drink up me 'arties! Yo ho!

Ashen

What did you try? If you post that, and what went wrong with it, maybe someone can sort out why it didn't work so you'll know for next time. (And, if you post failed attempts it'll stop me accusing you of not trying :))

Have you got it working as you want now?
I know what you're thinking ... Don't think that.

Gepard

Yes! Perfect! You will have a special place in my scrolling titles :)
Drink up me 'arties! Yo ho!

SMF spam blocked by CleanTalk