Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Inventory Questions  (Read 2409 times)

0 Members and 1 Guest are viewing this topic.

greg

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
Inventory Questions
« on: September 24, 2006, 02:42:08 AM »

Hi WME Folks,

I'm interested in creating a customized inventory so that I have more control over the interface.  (Basically, I'd like to make sure that all items, regardless of size, are centered within the cell.)

1. Within the builtin inventory structure, is it possible to center a sprite within a cell?

2. How would one go about creating a custom inventory?  My thought was to create a window and then position the inventory items within the window.  Can I do this with Item objects, or would I need to use Buttons or another form of UI object?  My first attempt was this which, as this post might suggest, failed miserably:

Code: [Select]
var current_point; // coordinates of upper-left corner of current tile
current_point.x = start_point.x;
current_point.y = start_point.y;

for (var i=0; i < Game.NumItems; i=i+1) {
var Item = Game.QueryItem(i);

// display and position the inventory item within the window
Item.X = current_point.x;
Item.Y = current_point.y;
Item.Active = true;

// update current_point
current_point.x = current_point.x + tile_size.x + tile_spacing.x;

// have we reached the end of the row?
if (current_point.x >= (start_point.x + ((tile_size.x + tile_spacing.x) * num_tiles.x))) {
current_point.x = start_point.x;
current_point.y = current_point.y + tile_size.y + tile_spacing.y;

// have we reached the end of the last row?
if (current_point.y >= (start_point.y + ((tile_size.y + tile_spacing.y) * num_tiles.y))) {
break;
}
}
}

3. So that I can center the item within a cell, is it possible to query the width and height of a sprite?

Thanks so much for your help!

Greg
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory Questions
« Reply #1 on: September 24, 2006, 06:06:31 PM »

Quote
1. Within the builtin inventory structure, is it possible to center a sprite within a cell?
It's possible by using sprites for the item images. In sprite definition you can move the "base point" to wherever you need it.

Quote
Can I do this with Item objects, or would I need to use Buttons or another form of UI object?
Yes, you'd need to use buttons. You'd query the inventory item objects, read their image properties and assign these images to the buttons.


Quote
3. So that I can center the item within a cell, is it possible to query the width and height of a sprite?
*checks the docs* Hmm, doesn't seem to be the case :( I'll have to add this somehow.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.031 seconds with 19 queries.