Does anyone know the difference between the variables labeled under “objects” and variables labeled under “iPhone/iPad?”
A variable underneath IPad will be a general variable stored as a local variable on that device. Object variables are variables that belong to objects. You could have an object variable called ‘apples’ or something, and have three objects. StarGirl, A circle and Sloth, for example. If you went into StarGirls code, you’d have a [(self) apples] variable, which is the apples variable, but only for stargirl. Let’s say you set the value of [(self) apples] to 7 in stargirls code.
If you went into sloths code and set [(self) apples] to 19, and printed both of those in each object, you get 7 for stargirl and 19 for sloth. They both use the variable ‘apples’ but for each object it holds a different value.
I hope that helped. If anything was unclear, please let me know and I’ll try my best to explain it again.
Object variables apply only to that object. If you apply it under a different object, it’s value will be “under a different name.”
Phone/iPad variables cannot be changed manually and can only be changed by manipulating the device, except if you created that variable manually.
Yeah, but technically you could have (going back to my previous example) a block in stargirls code saying SET VALUE (Sloth)apples TO 15
If you printed out (Sloth)apples you’d get 15 then because, using star girl, a different object, you changed the value of (Sloth)apples. So yes, I agree with the first part, but it depends on how you apply that variable.
Not necessarily, but for some of them, yes. If you make a new variable under IPad, you could manually set that value to something and it would remain constant unless you changed it. You could have a variable called ‘pixel size’ for a pixel art and use that as an iPad variable so that it would be the same throughout the project (because it’s a local variable relative to the project) but it wouldn’t depend, necessarily, on the device.
I’m not trying to contradict you or argue with you or say that you’re wrong, I’m just trying to explain it a bit more. Sorry if I came off as mean or something, that was not the intent.
Haha sorry I was rushing a bit
I don’t usually come on the forum that often anymore
These variables apply to every single object. They only have one value, which can be referenced and edited by any object. For example, you couldn’t have three clones each storing their x position, and only their x position in one variable.
These variables apply to only one object, and each object or clone can have their own value stored in it. They can have up to 4096 values at one time, since 4096 is the current maximum number of objects.
Saying we want each object to store its x position into a value like earlier, and ignoring the fact that the app does this automatically, we can replace the global variable with an object variable.
An important thing to know is that in the list of object on an object variable, everything except for self applies to an original object, so the object you can see on the editor’s stage.
Hope this helps.
You could read the post above for a useful tutorial, however an alternative would be going to this helpful post made by ThinBuffalo, which talks about different kind of variables. I have linked the post down below. Hope this helps!
Thanks @Petrichor for the answer!
I´m happy that you got an answer! The answers above are really detailed, I think.
Still a helpful topic