Picking an item and placing in hand

In my game, there are random chests in the map. but, I don’t know how to place an item into chests and how to pick up items and how to put those items in our hand. please write the code or send a webpage so I can read. thanks for reading :)  :wink:

Sounds like you are being far too ambitious with your project. If your skills were anywhere the required level, you’d just ‘know’ the answer.

Another analogy here, but if I was to learn carpentry I’d probably start with a table, then a chair, then a chest of drawers, rather than starting with a house…

It’s also a very hard question for anybody to answer, even if that person had made Legend of Zelda, because we have no idea how your project is set up, what your data or module structures are.

I agree with @nick_sherman, you’ve given us insufficient details about what you are doing to help.  i.e. Your description is very vague.

I could say this is an answer to your question, but I’m sure you’ll say, “That’s not what I meant”.

local chests = {} local hand = {} local function pick( self, event ) hand[self] = self chests[self] = nil self:removeEventListener('touch') end local function newItem( x, y ) local tmp = display.newCircle( x, y , 10 ) tmp.touch = pick tmp:addEventListener("touch") chests[tmp] = tmp end newItem( 100, 100 ) newItem( 100, 140 ) newItem( 100, 160 ) newItem( 100, 180 )

I found the answer. thanks for answering.

I can write a code that when my character touches that item, change the data of my character that if a zombie touches my character, gets died.

Sounds like you are being far too ambitious with your project. If your skills were anywhere the required level, you’d just ‘know’ the answer.

Another analogy here, but if I was to learn carpentry I’d probably start with a table, then a chair, then a chest of drawers, rather than starting with a house…

It’s also a very hard question for anybody to answer, even if that person had made Legend of Zelda, because we have no idea how your project is set up, what your data or module structures are.

I agree with @nick_sherman, you’ve given us insufficient details about what you are doing to help.  i.e. Your description is very vague.

I could say this is an answer to your question, but I’m sure you’ll say, “That’s not what I meant”.

local chests = {} local hand = {} local function pick( self, event ) hand[self] = self chests[self] = nil self:removeEventListener('touch') end local function newItem( x, y ) local tmp = display.newCircle( x, y , 10 ) tmp.touch = pick tmp:addEventListener("touch") chests[tmp] = tmp end newItem( 100, 100 ) newItem( 100, 140 ) newItem( 100, 160 ) newItem( 100, 180 )

I found the answer. thanks for answering.

I can write a code that when my character touches that item, change the data of my character that if a zombie touches my character, gets died.