Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: How to place pickable item in the scene?  (Read 2162 times)

0 Members and 1 Guest are viewing this topic.

interesting

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
How to place pickable item in the scene?
« on: December 29, 2006, 06:31:03 PM »

What should I do?
Help me please...
Logged

Nihil

  • Supporter
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 528
  • Fear me! I'm evil!
    • View Profile
    • Order of Dagon
Re: How to place pickable item in the scene?
« Reply #1 on: December 31, 2006, 02:58:57 PM »

One way is to create two graphics, one that represents the item in the scene, and one for the inventory object.
Copy the item graphic in the Items-folder of your project and add an entry for it in the items.items file.

You place the first one in the scene using SceneEdit -> create a new Sprite Entity (name it book for example) , use your image as sprite, and attach a script to it.
The script should contain something like this code:

Code: [Select]
on "Take"
{
Game.TakeItem("book_item"); //this adds the item to your inventory
var knife_n = Scene.GetNode("book"); //disable the sprite in scene so it's no longer visible
book_n.Active = false;
}

There are many examples for that in the demo projects. If you want to leave out the last two lines of the code you can also assign the item to the sprite in scene edit, there is a fill in called "item" where you just type in "book" (without the exclamation marks), they are then automatically connected together and the sprite disappears when you call Game.TakeItem("book") in your script.
 

Page created in 0.046 seconds with 23 queries.