loadJSON() displayes "loading..."

hi made a sprite editor that saves the sprite in a JSON format. When i try to load the JSON with loadJSON() in the pre load function the script will not run. Only the text " loading..." is displayed. I don't think I am doing something wrong here because even the reference page in on the p5 site shows the same bug. i tried different browsers and it has the same i issue. do i need to report this some where or is this a know issue? is there maybe a alternative for loadJSON() ?

here is a print screen from this issue on the reference page where the left canvas wouldn't load.

Screenshot 2016-12-13 19.21.20

Answers

  • aahh so just t use the loadTABLE() and saveTABLE() functions.

  • Oops! I guess 1st link led you astray. Forgot to pay attention it was about CSV instead of JSON! b-(

  • i am not loading the json from a site but loading in from the folder its in.

    even when i exactly follow this tutorial below i get the loading.. text.

  • It's hard to help w/o some pasteble & runnable code... [-(

  • edited December 2016

    this is a quik code to check if the sprite is loaded

    var sprite;
    
    var pixelSize = 20;
    
    var posX = 0
    var posY = 0
    
    
    function preload() {
        sprite = loadJSON("sprite_game/sprite.json");
    
    }
    
    
    
    function setup() {
        createCanvas(windowWidth, windowHeight)
        colorMode(HSB, 255)
        //sprites()
    
        console.log(sprite)
    }
    
    function windowResized() {
        resizeCanvas(windowWidth, windowHeight);
    }
    
    
    function draw() {
        background(40, 0, 0, 255)
    
        pixelSize = mouseX / 5
    
        translate(width / 2, height / 2);
        rotate(radians(mouseY))
        posX = 0 - pixelSize * 8
        posY = 0 - pixelSize * 8
    
    
    
    
    
    
        for (var i = 0; i < sprite.Width; i++) {
            for (var j = 0; j < sprite.Height; j++) {
    
    
    
                if (sprite.array[((i) + ((j) * sprite.Width))] > 0) {
    
                    stroke(sprite.array[((i) + ((j) * sprite.Width))] * 255 / 16, 255, 255)
                    fill(sprite.array[((i) + ((j) * sprite.Width))] * 255 / 16, 255, 255)
                    rect(i * pixelSize + posX, pixelSize * j + posY, pixelSize, pixelSize)
                }
    
            }
        }
    
    }
    
  • and the sprite.json file is.

    {
      "Width": 16,
      "Height": 16,
      "array": [
        0,
        0,
        0,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        0,
        0,
        0,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        6,
        0,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        9,
        9,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        9,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        8,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        8,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        8,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        8,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        9,
        9,
        9,
        8,
        8,
        8,
        9,
        8,
        9,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        9,
        8,
        9,
        9,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        9,
        9,
        9,
        9,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        9,
        9,
        9,
        8,
        8,
        8,
        8,
        8,
        6,
        0,
        0,
        6,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        8,
        6,
        0,
        0,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        0
      ]
    }
    
  • Where is function sprites()?! =;

  • oh sorry you have to delete that one. the function sprite is a copy of the json file to check if the code worked.

Sign In or Register to comment.