Help drawing inventory

Youpsy

  • Posts: 16
Hello

So here I am trying to draw the objects that contain my inventory but the I do not really know how to do :S

Basically I would like the items in my inventory to appear as an image if my bag is open.
a bit like in the attached image except that I want to replace the slots with my personal images, to navigate in the inventory I would have liked to drag it.

Here are the codes I use to draw

Thank you in advance to those who will waste a little of their time for me!

Luyren

  • *
  • Posts: 2346
First, get used to the Image API: http://www.stencyl.com/help/view/image-api

Your image "canvas" should be the size of the screen, and attached to the screen.
You will want to create an actor type that has one animation for each item available in your game. Create oneactor at each available display position, and store each one in a list. Each item in the list correspond to the same index in your inventory.

You'll loop through your actors, and change its animation to the name of the item in the inventory in the same index and draw its image on the canvas. If there is no item, either don't draw the actor's image, or switch to one specific image for empty slots.

That is the way I do it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Youpsy

  • Posts: 16
Thanks for your tips! I'll try it all!
A good evening !

Youpsy

  • Posts: 16
So here I create a list for the positions, to start 2 row / 2 column

Sorry to be a ball on the other hand I did not understand which block to use to create image instances of the actor "Items" which will include all my objects and especially how to define its animation.

Could you show me a visual example please?

Luyren

  • *
  • Posts: 2346
Check the attached image. I don't have a simpler example at hand though.
"Item Position Display" is a list attribute, that holds the position on screen of each item. On the list, each item is in the format "X,Y"
"Items List" is a list attribute that acts as a database, with the data for each item in my game. Each item has the information for the item in sequence, separated by a slash (like name/icon animation/description/etc).
"Icon Actor" is the actor I create when I open the menu. I check if it has value, then I switch its animation and draw it onto the canvas image.

Refer to my link on the previous post as to how to draw images.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Youpsy

  • Posts: 16
Thank you so much ! I'm going to test it all at home

Youpsy

  • Posts: 16

So here is what I did ..

I created the display list of the position of the article which I fed as you told me in "X, Y" format

I then created an actor and added images

0 = coconut
1 = Apple
2 = fish
etc ...

Then, I created the list of articles that I fed:

Coocnut, 0
Apple, 1
Fish, 2
etc ...

And finally I created the Icon Actor attribute for an actor

now the part I'm not sure I understood and well done ...

I placed these blocks in the "When drawing" event of my scene, is that correct?

For "Icon Actor" should I simply create a "Set Icon Actor" block in the "creation" event of my actor "icon"? Because I only found the block to create a type of actor.

Initial Diplay? Is this a list that contains the position of the menu window?

Used Inventory? Do I have to refer to "Saved Inventory Name" in the "Inventory" behavior that you created

Icons X and Y Offset I thought it was a list that worked the same way as "item position display" but no ...

Luyren

  • *
  • Posts: 2346
now the part I'm not sure I understood and well done ...

I placed these blocks in the "When drawing" event of my scene, is that correct?
Image blocks can be used anywhere. When drawing is fine.
Quote
For "Icon Actor" should I simply create a "Set Icon Actor" block in the "creation" event of my actor "icon"? Because I only found the block to create a type of actor.
You create the actor type, and set an "actor" attribute to  the last created actor when you open your inventory.
Quote
Initial Diplay? Is this a list that contains the position of the menu window?

Used Inventory? Do I have to refer to "Saved Inventory Name" in the "Inventory" behavior that you created

Icons X and Y Offset I thought it was a list that worked the same way as "item position display" but no ...
Replace "Used Inventory" with your own inventory list attribute. The rest you can ignore, as they pertain to my own code.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Youpsy

  • Posts: 16
Ok I think it's good for this part.

Now if I understand correctly for "Menu Image" I create a block "set Menu Image to? image from actor ? During the event" When created "

Alas when I test I have an error


« Last Edit: February 14, 2020, 12:32:21 pm by Youpsy »

Luyren

  • *
  • Posts: 2346
You put your list getters inside a boolean space, that's why you get the error.
Second, you seemed to just have copied the code, whereas I think it's more important that you understand it and try on your own. For example, you included the "width of screen / 2" on your code. While I have a reason for doing that, you don't have to. You also don't have to do the whole database setup I mentioned. You can just set your actor to the item's name, and by doing that you don't need the second loop "for each item in Item's List."
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Youpsy

  • Posts: 16
Sorry, I just have a little notion of vba because a few years ago I had just made a small program in Excel.

Otherwise I am completely a neophyte ..

Before copying I tried to get inspired by how you drew your objects in the debug mode of your "inventory" behavior

And yes I stupidly copy your code because I seemed to have understood how it worked .. but to see not quite ..

This is what I interpret from the Code _
"When drawing" if the bag is open you repeat all the positions that there are in Item list.
After if my character who has the inventory is alive and if has a value then you look in the inventory list for item 0 separated from /
Then you switch to the desired animation of actor Icon actor
And you draw it in the middle of the width and height of the "Inventory Panel" image

« Last Edit: February 15, 2020, 08:36:07 am by Youpsy »

Youpsy

  • Posts: 16
I think I'm starting to lose myself completely ...  :-[
and the worst part of it is that once i have managed to set it up i want to do crafting ...

Youpsy

  • Posts: 16
Good morning all !

I up the subject again!

I tried several times but it bug every time.
Did I not understand something else?

Youpsy

  • Posts: 16
Salut le forum !

Est ce qu'il y a des gens qui parlent français et qui pourrai m'expliquer comment fonctionnent les images api surtout côté acteur car ça fait bientôt 1 semaine que je suis dessus et je comprend vraiment pas..
Entre les vidéos russe ou des pages en anglais ma pauvre petite tête va finir par exploser :(

Une bonne soirée !

Luyren

  • *
  • Posts: 2346
Might be easier to disregard my sample code and go for a simpler approach. Create one actor at each position on screen you want your inventory items in, and switch its animation to the corresponding inventory slot item.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter