Since there are no tutorials on a drawing pad that I could find in search, I’ll just be modifying a project with this code:
This is just the default draw like a pen ability, which currently exists as of writing this post. If it is ever removed, let me know and I’ll edit the code for it in. (Nearly everything is removed though, so don’t worry too much)
The method for adding layers in this drawing pad uses a lot of clones which save two points each. This means that there is a limit on lines and that more lines could equal more lag. It also redraws the current layer using something similar to this:
It is not identical though. This constant redrawing is partially what makes lag when there are many lines. If you want to lessen the lag, try making it only redraw when necessary.
The first change is to remove the when ipad is tapped rule. It isn’t necessary.
This already breaks the old code.
In this drawing pad, the original object does no drawing. Move the check once if outside of the draw a trail block then delete the drawing block. Replace go to finger with create a clone… This should result in this code:
typing this on an iPad is so difficult
But since constant clones would add to lag (and change the way it draws), let’s add a delay to the cloning. Add this code anywhere in the project:
Try messing around with that value, it will make the lines longer. (Try drawing with jt set to 100)
Then, back inside the custom rule, add this code to the when pressed
The name of the variable will make sense later. If you’re confused about it being subtracted, try switching 1 with 0 then drawing (after you are able to draw)
Then add a when object is cloned rule. You’re done with the when pressed. Inside of the when cloned, let’s save the first point. (Remember I said each clone saves two points?)
Now let’s save a second point. But since variable blocks happen at basically the same time, if we just add it it will be the same as line one. We need to wait at least 1 frame for that. Luckily, there’s already a variabled actually called “frames between points”.
You’re done with the when object is cloned rule for now. Currently, it knows where to draw, but it doesn’t know how to draw.
Since esch clone saves two points and draws a line between those two points, it first has to go to the first point, then start drawing, then go to the second. I did this in 3 rules, though it may be possible to do in one. I just didn’t think of that at the time.
You can draw now, but there has been nothing about layers, just saving the current drawing into variables and drawing from those variables.
We need a way to select layers and to add new layers. Let’s add that.
Let’s add a new text which will create a new layer when tapped:
Make sure that’s a check if else.
Next let’s display the layer picker:
You can set the text to whatever you like.
Now when the clones sre tapped, they should set the layer you draw to totheir clone index. Let’s mske a new variable to track this.:
Now eack lin needs to know what layer it is on::
Now let’s make it only draw ehn the current layer is its layer:
Add this and to every drawing rule.
The color is always the same, unless you have used variables in each line clone to keep track of the current drawing color and use that, if you’e modifying an existinng art pad. Let’s just to show the different layers have it draw the color using the layer variable:
Now let’s add a show entire picture button, which will make the layers display in order of how they should. To do this, we want each layer to draw itself. The easiest way is to loop through all the layers and select them for a frame, this will make them draw.
Here’s a link to the project from this topic:
And a project using (something similar to) this as part of a more complete art pad: