GithubHelp home page GithubHelp logo

hilogames / hlspritekit Goto Github PK

View Code? Open in Web Editor NEW
254.0 254.0 18.0 1.68 MB

SpriteKit scene and node subclasses, plus various utilities.

License: MIT License

Objective-C 99.75% Ruby 0.14% Shell 0.11%

hlspritekit's People

Contributors

btraut avatar karlvoskuil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hlspritekit's Issues

Maybe add a HLLinearLayout?

This is only a suggestion.

HLLinearLayout basically lays out nodes in a linear fashion. There can be a property that sets whether the layout should lay nodes out from left to right, right to left, top to bottom, or bottom to top. The client code can also set how big the spacing between nodes will be.

It's basically a SpriteKit version of UITableView, except it's not a visible thing, just a layout manager. This can be useful in scenes like game settings and main menus.

What do you think?

Is there an easier way to set the color of a square in HLGridNode?

I basically just want to have a little enhancement on HLGridNode. Right now, I'm using this code to change the color of an individual square:

(grid!.squareNode(forSquare: 0) as! HLBackdropItemNode).normalColor = UIColor.blue

Maybe you can just make squareNode(forSquare:) return an HLBackdropItemNode instead? Alternatively, can you make a method like this:

grid!.setColor(forSquare: 0, to: UIColor.blue)

Or can you both do of these enhancements? I am not familiar with Objective-C so I can't make the changes myself.

compiler error when building for the device: multiple methods named 'size' found with mismatched result, parameter type or attributes

The building for simulator is OK, and works great!

But try to build on iOS device, get several errors(all errors are similar):

HLSpriteKit/HLSpriteKit/HLLayoutManager.m:36:12: error: multiple methods named 'size' found with mismatched result, parameter type or attributes
return [node size].width;

In module 'SpriteKit' imported from Pods/HLSpriteKit/HLSpriteKit/HLLayoutManager.m:9:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SpriteKit.framework/Headers/SKScene.h:58:30: note: also found
@Property (nonatomic) CGSize size;
^~~~
In module 'SpriteKit' imported from Pods/HLSpriteKit/HLSpriteKit/HLLayoutManager.m:9:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SpriteKit.framework/Headers/SKSpriteNode.h:163:30: note: also found
@Property (nonatomic) CGSize size;
^~~~
In module 'SpriteKit' imported from Pods/HLSpriteKit/HLSpriteKit/HLLayoutManager.m:9:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SpriteKit.framework/Headers/SKVideoNode.h:66:30: note: also found
@Property (nonatomic) CGSize size;

Can you lower the deployment target version to 8.0?

I'm installing the pod this way:

pod 'HLSpriteKit', :git => 'https://github.com/hilogames/HLSpriteKit.git'

When I pod install, cocoapods says

Specs satisfying the `HLSpriteKit (from `https://github.com/hilogames/HLSpriteKit.git`)` dependency were found, but they required a higher minimum deployment target.

I want my app to support iOS 8 so that more people can download it. I don't think this pod uses anything from iOS 9 or 10, right? Can you lower the deployment target?

HLScrollNode clips content but not gestures

I ended up writing my own version of your scroll node before I discovered HLSpriteKit and it looks like you ran into the same issue I did: SKCropNodes crop content, but they still intercept taps where that content would otherwise be drawn.

I've asked on StackOverflow how to prevent this, but it doesn't seem like SpriteKit gives us the tools. I suspect it has something to do with drawing and tap handling happening in different parts of the system. That in mind, my version of the scroll node still checked to see if a tap/pan/pinch/etc landed inside or outside the SKCropNode's visible content. If outside, it passed the event onto the next deepest node.

Does all that make sense? Does it sound reasonable? I could try to retro-fit it into HLScene.

I JUST WANT TO SAY THANKS!!

It's so amazing for what you did. It's really useful for me and maybe the most useful tool I have ever used. Thanks for your great job! YOU SAVED MY LIFE!

HLScrollNode

When I use HLScrollNode, size not control scroll's board

Does HLGridNode.setContent(_:) resets all the nodes in the grid node?

Let's say I have a grid node with 200 squares. And there are about 100 squares already with content in it. The contents are just single SKSpriteNodes with textures. Now every second, I want the content of at most 8 squares to change. By "change", I mean to change from having no content to having a single SKSpriteNode as content, or the other way around.

To do this, I need to call setContent(_:) every second. The parameter is an array that I maintained.

The question is that does setContent(_:)

  • remove all the contents in the grid node, then add each one from the array in? or;
  • only reset those squares that changed?

I need to know this because I'm afraid that if it does the former, it would waste a lot of time and memory since many of the squares' contents will remain unchanged after setContent(_:) and they will be reset anyway.

I don't want to use setContent(_:forSquare:) because it is too tedious...

Mac support

Any plans to support SpriteKit on Mac? I started trying to port myself, but there's some decisions that need to be made around gesture support given that it's somewhat different on the Mac. I'd love to use some of the utility nodes such as HLTileNode even without the gesture support.

Unable to layout SKLabelNodes using HLTableLayout

I want to lay out two label nodes using the code below:

    let anchorPoint = NSValue(cgPoint: CGPoint(x: 0.5, y: 0.5))
    let scoreboardNode = SKSpriteNode(color: UIColor.yellow.withAlphaComponent(0.77), size: CGSize(width: 700, height: 180))
    scoreboardNode.zPosition = 1001
    let scoreboardTableLayout = HLTableLayoutManager(columnCount: 1, columnWidths: [(0.0)], columnAnchorPoints: [anchorPoint], rowHeights: [(0.0)])!
    scoreboardTableLayout.rowSeparator = 15
    scoreboardNode.hlSetLayoutManager(scoreboardTableLayout)

    let scoreLabel = SKLabelNode(text: "SCORE:            0")
    scoreLabel.fontSize = 61
    scoreLabel.fontName = "Courier-Bold"
    scoreLabel.horizontalAlignmentMode = .center
    scoreLabel.fontColor = UIColor.black
    scoreboardNode.addChild(scoreLabel)

    let bestScoreLabel = SKLabelNode(text: "BEST:             0")
    bestScoreLabel.fontSize = 61
    bestScoreLabel.horizontalAlignmentMode = .center
    bestScoreLabel.fontName = "Courier-Bold"
    bestScoreLabel.fontColor = UIColor.black
    scoreboardNode.addChild(bestScoreLabel)

    scoreboardNode.hlLayoutChildren()

    self.addChild(scoreboardNode)

I basically created two label nodes, and called hlLayoutChildren. But it appears like this:

screen shot 2016-10-12 at 4 56 11 pm

The two labels are stuck together!

After some testing, I found out that if I set tableLayout.rowSeparator to a larger number, the distance between the two labels becomes larger.

Can you enhance the example project?

In the example project, I expect to see the usage of each of the features. But I feel like they are scattered everywhere in the file. Can you group the code with #pragma mark so that it is clear which is which?

At the moment, if I want to know how to use HLTableLayoutManager, I need to search for keywords in the file. And they are scattered everywhere. It's really hard to find.

Alternatively, can you show the usage of one feature in one scene?

HLToolbarNode.hideAnimated removes toolbar node from parent

I was looking to hide and show the toolbar when dragging an object in my world (to give more space on a mobile device).

I would expect to be able to use the hide and the show function provided, but the hide function removes the toolbar from the parent node, while the show function does not require a node to add the toolbar back to.

It feels like the hide action shouldn't remove the node from the parent. If I want to remove it from the parent also, then I could do that after, or add another param to the hide function; a boolean to remove from parent node or not. I had to dig through the code to work this out.

P.S. my game is progressing slowwwwly, but progress is neat =]

Can you reduce the number of nodes in HLGridNode?

I created a 10x20 grid node as I have said in my other issues.

    let grid = HLGridNode(gridWidth: 10, squareCount: 200, anchorPoint: CGPoint(x: 0.5, y: 0.5), layoutMode: .fill, squareSize: CGSize(width: 40, height: 40), backgroundBorderSize: 1, squareSeparatorSize: 2)
    self.addChild(grid!)

When I look at the node count at the bottom right, it says 404!

In the grid node, there should be 200 squares right? How can the total node count be double the number of squares? I understand that you need some node to put the content in, but can you remove that node if the content is NSNull?

Passing nil to gridNode.setContent results in error

In my grid node, I want to leave all but one square empty. So I created a 2D array of my model, and mapped it to a 1D array. After that, I mapped the 1D array again to get the SKSpriteNode objects from my mode.

var modelObjs: [[Model?]]

init(...) {
    // created a 2D array filled with nils. The array is 10x20
    let repeating: [Model?] = [Model?](repeating: nil, count: 20)
    models = [[Model?]](repeating: repeating, count: 10)
}

func syncModel() {
    someGridNode.setContent(models.flatMap { $0 }.map { $0?.node })
}

When I call syncModel, this error occurs:

[_SwiftValue setName:]: unrecognized selector sent to instance 0x60000024fff0

When I change the line in syncModel to this:

someGridNode.setContent(models.flatMap { $0 }.map { $0?.node ?? SKSpriteNode(color: UIColor.black, size: CGSize.zero) })

No errors occur.

So I suspect that the array I pass into setContent must no contain nil. But why? Why not make it so that if setContent sees a nil in the array, it removes the content from the square?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.