Hello friends 👋 I was here many years ago, disappeared for a while but am now back with a goal to learn Processing... and have gone all the way back to Coding Challenge 1 - Starfields!
I've been adding to the code myself (successfully converted from 2D to 3D 🎉 ) but have hit a snag wanting to add more stars while the sketch is running. I decided (perhaps incorrectly) that a good way to do this would be to create a small array of more Star objects, and concat() the two arrays when a key is pressed. But even troubleshooting in setup() I can't join these two arrays together.
Here's the relevant code. Why am I getting the error message Type mismatch: cannot convert from Object to cc_001_starfield_3d.Star[] ?
I've read and re-read the help page on concat() [https://processing.org/reference/concat_.html] but I don't understand why the example on that page String[] sa3 = concat(sa1, sa2); would work and the last line of my code here (which looks identical to me) doesn't? Can anyone explain/shed light? Why is Processing trying to convert? The objects are already the same type, right? aaaaaaaaah my brain! 🧠 🤯
Thank you in advance!
Star[] stars = new Star[400]; // an array to hold initial stars Star[] morestars = new Star[10]; // stars to be added each time "+" is pressed ... for (int i = 0; i < stars.length; i++) { stars[i] = new Star(); } for (int j = 0; j < morestars.length; j++) { morestars[j] = new Star(); } Star[] stars = concat(stars, morestars);