{"id":1140,"url":"https://github.com/bwide/CollectionNode","last_synced_at":"2025-07-30T20:32:45.558Z","repository":{"id":56906244,"uuid":"99288044","full_name":"bwide/CollectionNode","owner":"bwide","description":"a collectionView made for Sprite Kit","archived":false,"fork":false,"pushed_at":"2018-08-20T02:18:53.000Z","size":21863,"stargazers_count":101,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-01T16:02:18.603Z","etag":null,"topics":["carthage","collection","collectionview","spritekit","swift","view","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bwide.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-04T01:01:42.000Z","updated_at":"2024-09-28T08:36:24.000Z","dependencies_parsed_at":"2022-08-21T02:20:50.175Z","dependency_job_id":null,"html_url":"https://github.com/bwide/CollectionNode","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwide%2FCollectionNode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwide%2FCollectionNode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwide%2FCollectionNode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwide%2FCollectionNode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwide","download_url":"https://codeload.github.com/bwide/CollectionNode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187556,"owners_count":17882325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","collection","collectionview","spritekit","swift","view","xcode"],"created_at":"2024-01-05T20:15:39.764Z","updated_at":"2024-12-04T20:31:04.352Z","avatar_url":"https://github.com/bwide.png","language":"Swift","funding_links":[],"categories":["Games"],"sub_categories":["Getting Started","Other free courses","Linter"],"readme":"# CollectionNode \n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) \n[![Badge w/ Version](https://cocoapod-badges.herokuapp.com/v/NSStringMask/badge.png)](https://cocoapods.org/pods/CollectionNode) \n![MIT](https://cocoapod-badges.herokuapp.com/l/NSStringMask/badge.png) \n![Swift 4.0.x](https://img.shields.io/badge/Swift-4.0.x-orange.svg)\n[![Build Status](https://travis-ci.org/bwide/CollectionNode.svg?branch=master)](https://travis-ci.org/bwide/CollectionNode)\n\n A collectionView made for Sprite Kit\n \n ![Preview](https://github.com/bwide/BWCollectionView/blob/master/iphonePreview.gif)\n\n## installation\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a dependency manager that provides binary frameworks for your projects.\n\nyou can install Carthage through [Homebrew](http://brew.sh/), with the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nThen you need to tell carthage to integrate this framework in your Xcode project, by adding the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile):\n\n```ruby\ngithub \"bwide/CollectionNode\"\n```\n\nNow:\n\n1. On your project folder, run `carthage update` \n1. On your application target, drag `BWCollectionView.framework` into your Xcode project `Embedded Binaries`\n\n### CocoaPods\n\nAdd this to your [Podfile](https://guides.cocoapods.org/syntax/podfile.html)\n\n```ruby\npod 'CollectionNode'\n```\n\n\n### important\n\nIf you plan to upload your app you must follow additional instructions on Carthage's [README](https://github.com/Carthage/Carthage/blob/master/README.md) on adding frameworks to your application if you're building for iOS, tvOS, or watchOS.\n\n## usage\n\n1. Import  ```CollectionNode``` module on your  ```CollectionNodeScene```  class:\n\n```swift\nimport CollectionNode\n```\n\n2. Add a ```CollectionNode``` to ```CollectionNodeScene``` and set it's dataSource and Delegate:\n\n```swift\nprivate var myCollectionNode: CollectionNode!\n\noverride func didMove(to view: SKView) {\n    myCollectionNode = CollectionNode(at: view)\n\n    myCollectionNode.dataSource = self\n    myCollectionNode.delegate = self\n\n    addChild(myCollectionNode)\n}\n```\n\n3. Conform this ```CollectionNodeScene``` to ```CollectionNodeDataSource``` and implement all it's methods:\n```swift\nextension GameScene: CollectionNodeDataSource {\n    func numberOfItems() -\u003e Int {\n        return EmojiModel.default.emojis.count\n    }\n\n    func collectionNode(_ collection: CollectionNode, itemFor index: Index) -\u003e CollectionNodeItem {\n        //create and configure items\n        let item = EmojiItem()\n        item.emoji = EmojiModel.default.emojis[index]\n        return item\n    }\n}\n```\n4. Conform to ```CollectionNodeDelegate```and override the methods that you need:\n```swift\nextension GameScene: CollectionNodeDelegate {\n\n     func collectionNode(_ collectionNode: CollectionNode, didShowItemAt index: Index) {\n        let growAction = SKAction.scale(to: 1.3, duration: 0.15)\n        let shrinkAction = SKAction.scale(to: 1, duration: 0.15)\n\n        collectionNode.item(at: index).run(growAction)\n        collectionNode.children.filter{ emojiCollection.children.index(of: $0) != index }.forEach{ $0.run(shrinkAction) }\n    }\n\n    func collectionNode(_ collectionNode: CollectionNode, didSelectItem item: CollectionNodeItem, at index: Index) {\n        print(\"selected \\(item.name ?? \"noNameItem\") at index \\(index)\")\n    }\n}\n```\n\n5. Update your ```CollectionNode``` with the scene:\n\n```swift\noverride func update(_ currentTime: TimeInterval) {\n    collectionNode.update(currentTime)\n}\n```\n\n6. Now ```CollectionNode```will work with it's default implementation.\n\n### Properties\n\n```swift\nprivate(set) public var index: Int\n```\nthe current index of the CollectionNode\n\n```swift\npublic weak var dataSource: CollectionNodeDataSource?\n```\nthe object that acts as data source for the collection view\n\n```swift\npublic weak var delegate: CollectionNodeDelegate?\n```\nthe object that acts as delegate for the collection view\n\n```swift\npublic var spaceBetweenItems: CGFloat\n```\nthe spacing between elements of the CollectionNode\n\n```swift\npublic var items: [CollectionNodeItem]\n```\nreturns all the children of this node that are CollectionNodeItems\n\n### Methods\n\n```swift\npublic func update(_ currentTime: TimeInterval, dampingRatio: Double)\n```\nTo be called on the scene's update. Allows this node to animate when touch is released\ndampingRatio: the ratio for the collectionNode deacceleration (0 to 1 meaning the percentage of speed to deaccelerate when touch is released, default is 1%)\n\n```swift\npublic func snap(to index: Index, withDuration duration: Double)\n```\nsnaps to an item at a given index\nduration: The duration of the snap animation in seconds (default is 0.3)\n\n```swift\npublic func reloadData()\n```\nreloads all the items in the collection\n\n\n### CollectionNodeDelegate\n\n```swift\nfunc collectionNode(_ collectionNode: CollectionNode, didShowItemAt index: Index) -\u003e Void\n```\nreturns the number of items to be displayed on this collectionNode\n\n\n```swift\nfunc collectionNode(_ collectionNode: CollectionNode, didSelectItem item: CollectionNodeItem, at index: Index ) -\u003e Void\n```\ncalled each time an item is selected\n\n### CollectionNodeDataSource\n\n```swift\nfunc numberOfItems() -\u003e Int\n```\nhere you should tell the number of items this collection will display\n\n\n```swift\nfunc collectionNode(_ collection: CollectionNode, itemFor index: Index) -\u003e CollectionNodeItem\n```\nhere you should return an item for each index in the collectionVIew\n\n## Apps using CollectionNode\n\n* [Tiles](https://itunes.apple.com/br/app/tiles-puzzle-game/id1253612564?mt=8)\n\n![Preview](https://github.com/bwide/CollectionNode/blob/master/tiles.gif)\n\nShow me your apps! if you have used this collection i'd love to see it, reach me in ```bfwide07@gmail.com``` you can send me images and i will post them here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwide%2FCollectionNode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwide%2FCollectionNode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwide%2FCollectionNode/lists"}