Posts

Post not yet marked as solved
0 Replies
592 Views
I am in the process of building a fairly complex game in SpriteKit. Per Apple's documentation (see https://developer.apple.com/documentation/spritekit/sknode/controlling_user_interaction_on_nodes) there are two main ways of handling events in a SpriteKit game. One is to handle all user interaction from a single node, the main SKScene in my case. I attach gesture recognizers in the SKScene.didMove(to:) method and test for which nodes were interacted with, then trigger the appropriate event based on the node. This is the technique I am currently using because it seems to be what everyone recommends, based on online research. The second approach involves attaching gesture recognizers on a node-by-node basis. I am quickly running into a scale problem of handling all the events at the SKScene level (the first approach). Currently I am checking which nodes were touched using the name of the node, then triggering the appropriate event based on the touched node. This worked fine when I had around a dozen different nodes the user could interact with, but it is quickly getting out of control as I build out my game and add dozens and dozens of different nodes that are capable of being interacted with. This technique does not seem scalable at all. I would like to start exploring attaching gesture recognizers to the individual nodes, but I cannot find a single example anywhere online of this technique. I have also purchased and read a book on SpriteKit, which only describes the former technique. Can anyone point me in the right direction, provide some code examples, or tell me where I might find information about how to better scale out a SpriteKit game, specifically in terms of event handling?
Posted
by jsclev.
Last updated
.
Post not yet marked as solved
0 Replies
1.2k Views
I am aware that this question has been asked before, but the answer seems to have changed over the years, and other answers online are still not clear to me. Currently (May 2022), it seems like Apple will allow Lua scripts to be run from inside an iOS app, but I am hoping someone can provide a definitive answer. I am planning on building a Lua scripting engine into my iOS game engine to allow AI designers to control the game's AI. The game engine is written in Swift and SpriteKit and targets iOS on iPhone and iPad. I am including the Lua scripts bundled with my application bundle, which are interpreted at runtime by a Lua interpreter that I am also including inside the application bundle. I believe section 3.3.2 of the Apple Developer Program License Agreement is the pertinent section, and it sounds like using Lua scripts that are interpreted at runtime by an iOS app is fine. If anyone can offer any further confirmation or guidance to my interpretation, it would be much appreciated. My Lua scripts are directly related to the primary purpose of my app (AI scripts for a game). I posted this question on StackOverflow, but it was closed because I was told the question seeks legal advice rather than technical advice, so if that will be true here as well, can anyone tell me where I should go to ask this question?
Posted
by jsclev.
Last updated
.
Post not yet marked as solved
1 Replies
830 Views
I am trying to use GameplayKit's GKGridGraph for a turn-based strategy game. A typical way of using this data structure seems to be to initialize a new GKGridGraph by passing it the grid dimensions, plus a few other params. This results in a fully constructed and connected grid graph of nodes. Then the technique I have seen is to manually remove the nodes that you don't want your agent to be able to traverse, for later usage of findPath(). However, I have found the remove() method to be really bad on performance, for example it takes around 100x longer to call the remove() method than to add a node to the grid graph. I do not know if this is a bug in the framework or not. That performance is going to be a show-stopper for me, so using that technique is not going to be an option for me. I can post all requisite code if there is anyone out there who knows anything about how to use GKGridGraph. Does anyone know how to construct a grid-aware, fully connected GKGridGraph correctly using only the nodes that you want to be in the graph? Also, if there are any Apple support/engineers out there reading this, wow it is hard to get started with GameplayKit due to lack of documentation/tutorials/project samples that are anything more than just the most basic simple use cases. I do believe that GameplayKit is a very well designed framework, but any examples beyond the basics seem to be non-existent anywhere on the internet (March 2022), and the API docs are woefully too little information to get started beyond a Flappy Bird clone. I am attempting to build a professional game. For example, I was not able to find a single example anywhere of how to use a GKGridGraph with a sub-classed GKGridGraphNode class, and then to prep the grid for traversal and usage of findPath(). This technique is only vaguely hinted at in the Apple-supplied Pathfinding sample project at Pathfinding Sample Project. Any help would be greatly appreciated. I am considering abandoning GameplayKit simply due to lack of documentation at this point, but I do believe underneath it is a really good framework, if you know things about it beyond what the API docs tell you.
Posted
by jsclev.
Last updated
.