a collectionView made for Sprite Kit

Overview

CollectionNode

Carthage compatible Badge w/ Version MIT Swift 4.0.x Build Status

A collectionView made for Sprite Kit

Preview

installation

Carthage

Carthage is a dependency manager that provides binary frameworks for your projects.

you can install Carthage through Homebrew, with the following command:

$ brew update
$ brew install carthage

Then you need to tell carthage to integrate this framework in your Xcode project, by adding the following to your Cartfile:

github "bwide/CollectionNode"

Now:

  1. On your project folder, run carthage update
  2. On your application target, drag BWCollectionView.framework into your Xcode project Embedded Binaries

CocoaPods

Add this to your Podfile

pod 'CollectionNode'

important

If you plan to upload your app you must follow additional instructions on Carthage's README on adding frameworks to your application if you're building for iOS, tvOS, or watchOS.

usage

  1. Import CollectionNode module on your CollectionNodeScene class:
import CollectionNode
  1. Add a CollectionNode to CollectionNodeScene and set it's dataSource and Delegate:
private var myCollectionNode: CollectionNode!

override func didMove(to view: SKView) {
    myCollectionNode = CollectionNode(at: view)

    myCollectionNode.dataSource = self
    myCollectionNode.delegate = self

    addChild(myCollectionNode)
}
  1. Conform this CollectionNodeScene to CollectionNodeDataSource and implement all it's methods:
extension GameScene: CollectionNodeDataSource {
    func numberOfItems() -> Int {
        return EmojiModel.default.emojis.count
    }

    func collectionNode(_ collection: CollectionNode, itemFor index: Index) -> CollectionNodeItem {
        //create and configure items
        let item = EmojiItem()
        item.emoji = EmojiModel.default.emojis[index]
        return item
    }
}
  1. Conform to CollectionNodeDelegateand override the methods that you need:
extension GameScene: CollectionNodeDelegate {

     func collectionNode(_ collectionNode: CollectionNode, didShowItemAt index: Index) {
        let growAction = SKAction.scale(to: 1.3, duration: 0.15)
        let shrinkAction = SKAction.scale(to: 1, duration: 0.15)

        collectionNode.item(at: index).run(growAction)
        collectionNode.children.filter{ emojiCollection.children.index(of: $0) != index }.forEach{ $0.run(shrinkAction) }
    }

    func collectionNode(_ collectionNode: CollectionNode, didSelectItem item: CollectionNodeItem, at index: Index) {
        print("selected \(item.name ?? "noNameItem") at index \(index)")
    }
}
  1. Update your CollectionNode with the scene:
override func update(_ currentTime: TimeInterval) {
    collectionNode.update(currentTime)
}
  1. Now CollectionNodewill work with it's default implementation.

Properties

private(set) public var index: Int

the current index of the CollectionNode

public weak var dataSource: CollectionNodeDataSource?

the object that acts as data source for the collection view

public weak var delegate: CollectionNodeDelegate?

the object that acts as delegate for the collection view

public var spaceBetweenItems: CGFloat

the spacing between elements of the CollectionNode

public var items: [CollectionNodeItem]

returns all the children of this node that are CollectionNodeItems

Methods

public func update(_ currentTime: TimeInterval, dampingRatio: Double)

To be called on the scene's update. Allows this node to animate when touch is released dampingRatio: the ratio for the collectionNode deacceleration (0 to 1 meaning the percentage of speed to deaccelerate when touch is released, default is 1%)

public func snap(to index: Index, withDuration duration: Double)

snaps to an item at a given index duration: The duration of the snap animation in seconds (default is 0.3)

public func reloadData()

reloads all the items in the collection

CollectionNodeDelegate

func collectionNode(_ collectionNode: CollectionNode, didShowItemAt index: Index) -> Void

returns the number of items to be displayed on this collectionNode

func collectionNode(_ collectionNode: CollectionNode, didSelectItem item: CollectionNodeItem, at index: Index ) -> Void

called each time an item is selected

CollectionNodeDataSource

func numberOfItems() -> Int

here you should tell the number of items this collection will display

func collectionNode(_ collection: CollectionNode, itemFor index: Index) -> CollectionNodeItem

here you should return an item for each index in the collectionVIew

Apps using CollectionNode

Preview

Show me your apps! if you have used this collection i'd love to see it, reach me in [email protected] you can send me images and i will post them here.

You might also like...
Cusom CollectionView card layout
Cusom CollectionView card layout

MMCardView Example To run the example project, clone the repo, and run pod install from the Example directory first. Demo 1.Card Requirements iOS 8.0+

:star: Custom card-designed CollectionView layout

CardsLayout CardsLayout is a lightweight Collection Layout. Installation CocoaPods You can use CocoaPods to install CardsLayout by adding it to your P

Cellmodel-driven collectionview manager

Sapporo [] (https://github.com/Carthage/Carthage) cellmodel-driven collectionview manager Features Easy to manage your sections and cells (reset/inser

💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)
💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)

⚠️ The latest updates is this PR. It changes the difference algorithm to DifferenceKit. DataSources 💾 🔜 📱 Type-safe data-driven List-UI Framework.

 Easy way to integrate pagination with dummy views in CollectionView, make Instagram
Easy way to integrate pagination with dummy views in CollectionView, make Instagram "Discover" within minutes.

AZCollectionView Controller Features Automatic pagination handling No more awkward empty CollectionView screen AZ CollectionVIew controller give you a

A CollectionView Layout displaying a slanted cells
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

CollectionView - UICollectionView using UICollectionViewCompositionalLayout

CollectionView UICollectionView using UICollectionViewCompositionalLayout create

Custom CollectionViewLayout class for CollectionView paging mode to work properly
Custom CollectionViewLayout class for CollectionView paging mode to work properly

PagingCollectionViewLayout About How to use About ⚠️ Custom class, which is inherited from UICollectionViewFlowLayout, developed for properly work Col

Clocks made out of clocks made out of code

Clocks I came across this digital clock composed out of a set of analog clocks, created by Humans Since 1982, in a tweet, so I decided to remake it in

Elegant SVG animation kit for swift
Elegant SVG animation kit for swift

Elephant This is SVG animation presentation kit for iOS. Example You can run example app. Please open Example-iOS/Elephant-iOS.xcworkspace! Usage You

VEditorKit - Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)
VEditorKit - Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)

VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want.

Kit for building custom gauges + easy reproducible Apple's style ring gauges.
Kit for building custom gauges + easy reproducible Apple's style ring gauges.

GaugeKit ##Kit for building custom gauges + easy reproducible Apple's style ring gauges. - Example Usage Open GaugeKit.xcworkspace and change the sch

iOS SwiftUI starter kit based on Sketch Elements.
iOS SwiftUI starter kit based on Sketch Elements.

iOS Sketch Elements iOS Sketch Elements is iOS SwiftUI starter kit based on Sketch Elements. More information and screenshots here. Roadmap General Na

App Design Kit is a collection of beautifully designed, ready-to-use, iOS app template screens.
App Design Kit is a collection of beautifully designed, ready-to-use, iOS app template screens.

App Design Kit is a collection of beautifully designed, ready-to-use, iOS app template screens. This well-structured, Swift coded, UI Kit bundle helps you to create your own application much faster than starting from scratch, using a simple design file.

A Swift Formatter Kit
A Swift Formatter Kit

Format A Swift formatter kit. Simple formatting syntax for decimal numbers, currency, mass, addresses, ordinal numbers and hexadecimal colors. Usage I

EU Digital COVID Certificate Kit for the Apple Platform  (unofficial)
EU Digital COVID Certificate Kit for the Apple Platform  (unofficial)

EU Digital COVID Certificate Kit A Swift Package to decode, verify and validate EU Digital COVID Certificates for iOS, tvOS, watchOS and macOS Disclai

a custom language construction kit

Swifties a custom language construction kit intro Swifties aims to provide a flexible toolkit for creating custom languages in Swift. demo A custom Li

Applozic UI Kit in Swift
Applozic UI Kit in Swift

Official iOS Swift SDK for Chat 💬 Introduction 🌀 Applozic brings real-time engagement with chat, video, and voice to your web, mobile, and conversat

A Lightweight But Powerful Color Kit (Swift)
A Lightweight But Powerful Color Kit (Swift)

BCColor A lightweight but powerful color kit (Swift) Features Pick Colors From Image Generate Monochrome Image Support Hex Color Style Lighten / Darke

Comments
  • Support for tvOS

    Support for tvOS

    I've added a target for tvOS on CollectionNode.swift and changed the behaviour of calling collectionNode(_ collectionNode: CollectionNode, didSelectItem item: CollectionNodeItem, at index: Index ) to be called when the tv remote selection button is pressed, instead of a simple tap on the remote pad, which, I think, is a more expectable behaviour on tvOS. I did not update the example code for tvOS.

    opened by miguelnery 0
  • Update function can randomly cause a crash

    Update function can randomly cause a crash

    Report a bug

    What did you expect to happen?

    Swiping across the collection node and the app not crashing.

    What actually happened?

    Swiping across the collection node crashes. According to Xcode, the crash occurs within the update function of the collection node and the line causing the crash is printed below.

           let distance = -(trueVelocity * time)
    

    What are the steps to reproduce that?

    Its occurs when swiping the collection node but its not something that happens every time. Its random. Its happened a few times on my device and other test devices. Like I said, its not always crashing but you may get a random crash here and there.

    Environment

    Version of:

    • the CollectionNode:

    • Swift: 4

    • iOS: 10.1.1

    • Device: iPhone 6S Plus

    • Xcode:

    • If you use Cocoapods: run pod env | pbcopy and insert here

    • If you use Carthage: run carthage version | pbcopy and insert here

    opened by FlorianML 4
Owner
Bruno Wide
iOS Developer and swift thinker
Bruno Wide
iPhone and iPod Touch version of Skeleton Key: is an addictive and unique puzzle game in which you shift keys around the board unlocking treasure chests. Made with cocos2d-iphone.

Skeleton Key (iOS) Skeleton Key is an addictive and unique puzzle game in which you shift keys around the board unlocking treasure chests. It's availa

null 117 Jun 6, 2022
A simple dice roller made with pure SwiftUI.

Dice Roller A simple dice roller made with pure SwiftUI. Contributing Pull requests are welcome. For major changes, please open an issue first to disc

Adrien 0 Dec 13, 2021
The Classic game TicTacToe made using SwiftUI and MVVM architecture

The Classic game TicTacToe made using SwiftUI and MVVM architecture

Mehrdad 0 Oct 20, 2022
BabySortingToyGame - Build a little game for babies to sort shapes in the correct location. This is made in SwiftUI using drag gestures.

This is a demo to build a little mini-game "for babies". It's inspired in this kind of games:

Pedro Rojas 17 Oct 23, 2022
ShooterGame - An iOS App that is a shooter game. Made with SpriteKit and Swift

Shooter Game This project was created based on the challenge of Day 66 of the 10

António Pedro da Silva Rocha 0 Feb 1, 2022
This is a clone project of Wordle. The app is made using SwiftUI

Wordle This is a clone project of Wordle. The app is made using SwiftUI. You can

HZ.Liu 5 Nov 25, 2022
Easy way to integrate pagination with dummy views in CollectionView, make Instagram "Discover" within minutes.

AZCollectionView Controller Features Automatic pagination handling No more awkward empty CollectionView screen AZ CollectionVIew controller give you a

Afroz Zaheer 95 May 11, 2022
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
Fancy news app that diwnloads data from new.com api and shows it in a paging collectionview.

Fancy news reader PAging collection view that shows latest news from techcurch.com and displays full content in a detail page, was built to practice t

Abdul-Mujeeb Aliu 31 Feb 10, 2022
Aplicativo simples demonstrando como implementar ContextMenu em uma CollectionView

Aplicativo simples demonstrando como implementar ContextMenu em uma CollectionView Ambiente de desenvolvimento Estas são as versões das ferramentas qu

Junior Silva 0 Nov 26, 2021