File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed
src/content/examples/en/14_Loading_And_Saving_Data Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,6 @@ let mousePressY = 0;
88// Remember whether bubble is currently being created
99let creatingBubble = false ;
1010
11- // Put any asynchronous data loading in preload to complete before "setup" is run
12- function preload ( ) {
13- // Load the JSON file and then call the loadData() function below
14- loadJSON ( '/assets/bubbles.json' , loadData ) ;
15- }
16-
1711// Convert saved bubble data into Bubble Objects
1812function loadData ( bubblesData ) {
1913 bubbles = [ ] ;
@@ -31,9 +25,11 @@ function loadData(bubblesData) {
3125 }
3226}
3327
34- function setup ( ) {
28+ async function setup ( ) {
3529 let p5Canvas = createCanvas ( 640 , 360 ) ;
3630
31+ await loadJSON ( '/assets/bubbles.json' , loadData ) ;
32+
3733 // When canvas is clicked, call saveMousePress()
3834 p5Canvas . mousePressed ( saveMousePress ) ;
3935
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ function loadData(table) {
2525 // Put object in array
2626 bubbles . push ( new Bubble ( x , y , radius , name ) ) ;
2727 }
28+ return table ;
2829}
2930
3031async function setup ( ) {
You can’t perform that action at this time.
0 commit comments