Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Picking an item and placing in hand
Started by arshiasamiezad Jun 26 2018 02:13 AM

3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

arshiasamiezad

[GLOBAL: userInfoPane.html]
arshiasamiezad
  • Observer

  • 4 posts
  • Corona SDK

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 :)  ;)



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,519 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,978 posts
  • Corona SDK

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 )


[TOPIC: post.html]
#4

arshiasamiezad

[GLOBAL: userInfoPane.html]
arshiasamiezad
  • Observer

  • 4 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]