The game I am making involves a lot of nodes spawning at the top of canvas (off canvas) and then moving down the canvas. Does anyone have any suggestions to better handle determining when the nodes are passed the bottom of the canvas?
Just curious because I’m tired of constantly determining nodes Y positions (plus half their height) to check if they are off the canvas. It would be great if there was a way in Cocos Creator to aid in these calculations that I don’t know about yet. I also prefer to not use collisions unless they aren’t as expensive as I think they are? There will be a LOT of nodes on the screen.
I should add that doing this entirely in code is perfectly fine. I’m just curious if there are features of the editor that I’m not taking advantage of that I don’t know about because I’m new (very new… two/three days in, new).
Taking a look through the source it seems to only work with the camera culling mask settings. It no longer reports as true if I disable the culling mask in the camera settings that the node belongs to, but it would be handy if nodes had a “lastRendered” type of property or a “drawing” flag.
Thank you, I didn’t know about Camera.containsNode(). However, in my quick test, containsNode() seems to be always claiming true, for nodes that are not only out of view, but are also marked inactive.
I had just continued doing the calculations manually. However, if anyone else out there runs into this thread looking for an idea, I ended up doing a couple things.
I tried a hidden collider at the bottom of the screen. This worked nicely but I was already far along doing the manual method that I didn’t want to rewrite everything dealing with the onCollisionEnter event. If I had thought of this before I started coding everything I would have definitely used it.
I ended up making a bounds check for my purposes. I will share the method I used, and then attempt to add onto it for a more universal approach.
I’m assuming it’s the same node? I had seen cc.find() looking through random documentation/help. I assumed cc.find() would run an iteration to find the node by name, and I thought this.node.parent is a direct link to the node object.