Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only 1/2 of the bubbles are presented #91

Open
3 of 4 tasks
jesster2k10 opened this issue Apr 4, 2020 · 7 comments
Open
3 of 4 tasks

Only 1/2 of the bubbles are presented #91

jesster2k10 opened this issue Apr 4, 2020 · 7 comments

Comments

@jesster2k10
Copy link
Contributor

There is an issue in the current version of the library to which only half of the specified nodes are shown. This issue is related to #89, however, I thought it would be better to open a much more conclusive issue.

New Issue Checklist

Issue Description

The issue stems from the Magnetic view showing only half the number of nodes .i.e. showing 8 opposed to 15 nodes.

The cause of the issue is unknown, however, after some investigation, it seems to be that it has to do with the node.position set in the addChild function.

When I run print(node.position) I get the following in the console:

(0.0, 0.0)
(-105.53099822998047, -85.56782531738281)
(110.28900146484375, -44.71046829223633)
(-124.88300323486328, -49.56586456298828)
(80.25800323486328, -63.09857940673828)
(-150.05499267578125, 25.044469833374023)
(113.4219970703125, -64.8022232055664)
(-101.36699676513672, 93.44188690185547)
(137.75799560546875, -63.273929595947266)
(-143.57000732421875, -19.013620376586914)
(85.4530029296875, -7.014369964599609)
(-110.39099884033203, -63.73573303222656)
(137.75799560546875, -54.6263313293457)
(-118.06199645996094, 85.56877899169922)
(123.26599884033203, 119.49418640136719)
(-115.60199737548828, -95.26038360595703)

and only 8 elements are shown on the screen like so:

Simulator Screen Shot - iPhone 11 - 2020-04-04 at 20 14 44

however, when using the absolute position on both the x and y axis, so the node.position = CGPoint(x: abs(x), y: abs(y)),

and extra two elements are shown:

Simulator Screen Shot - iPhone 11 - 2020-04-04 at 20 16 12

Despite that, when showing the nodes count, 47 nodes are drawn onto the screen, more than are visible:

Simulator Screen Shot - iPhone 11 - 2020-04-04 at 20 18 20

So, my hypothesis is that the issue with only half of the items being shown stems with the positions they are assigned.

In particular, these lines in Magnetic.swift

override open func addChild(_ node: SKNode) {
        var x = -node.frame.width // left
        if children.count % 2 == 0 {
            x = frame.width + node.frame.width // right
        }
        let y = CGFloat.random(node.frame.height, frame.height - node.frame.height)
        node.position = CGPoint(x: abs(x), y: abs(y))
        print(node.position)
        super.addChild(node)
    }

Environment

  • iOS Version: iOS 13.3
  • Device(s): iPhone 11

It's worth nothing that this code is running in a react-native wrapper, from a library that I created around this https://github.com/jesster2k10/react-native-bubble-select

@jesster2k10
Copy link
Contributor Author

As I suspected, setting the node.position.y to 0 causes all of the nodes to appear like so:

Simulator Screen Shot - iPhone 11 - 2020-04-04 at 20 23 50

So my idea now, is that when the y-position is set randomly, there is a certain boundary, possibly the physics body, stopping the nodes from moving into the centre screen

@nurlan-dzhavadov
Copy link

Any progress on this?

@jesster2k10
Copy link
Contributor Author

@dvlpd Are you working with the react-native or iOS library?

@nurlan-dzhavadov
Copy link

I work with iOS library, sir

@nurlan-dzhavadov
Copy link

any updates?

@josepedromonteiro
Copy link

Hey @jesster2k10 any updates for the react-native lib?

@taier
Copy link

taier commented Dec 12, 2020

are you adding nodes inside viewDidLoad?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants