Search code examples
objective-csprite-kitselectediteminventory

RPG inventory class for carrying & trading with npc's


My goal is to make an item & inventory system like they have in the game called Runescape for my single player iPhone RPG game, with SpriteKit. They have a lot of items, which is what I want to implement: such as wood, bread, different types of catchable fish. They also have a 4x7 inventory (4 columns & 7 rows) where items are re-arrangeable with the mouse by clicking & dragging. So when you trade with an NPC shopkeeper, you have your inventory & theirs open up & you commence trading by dragging & dropping. From my end, world creation and main character & NPC placement is complete. The touch controls of the main character are also complete. However, now I have no idea how to tackle this mountain of a problem with the inventory & items. The tid-bits of scattered information I could find on the internet makes me panic even more, due to a lack of any tutorial on the matter - I don't know where to begin or what questions to ask. I'm a novice programmer. Could someone recommend some form of tutorial? If non exist for Objective-C then for any other programming language would do I guess. As long as I can look at the code. At which point I'll try to figure something out. Thank you in advance to anyone with any form of solution.

P.S. Should I begin learning Core Data for the database? Should begin learning how to save things to plists?


Solution

  • Unfortunately your question isn't very clear and hard to answer. I can say that you should learn Core Data if you wish to have persistence between app launches especially with the scope of your project.

    My recommendation is attack this problem in two parts. First attack storing picking up and stacking items and putting them into an Array of items for your character. This should be more of a "model" attack to the problem. After you have that working and items are being added I would then attack the SpriteKit or "view" aspect of the issue.

    I have actually been working on a similar thing and you can see my GitHub for the project here. Maybe you will find something there you can use and implement it in your game.

    Again sorry if it doesn't directly answer your question but at least it might get you started in the right direction.