My sketch in Javascript doesn't load the images...

edited December 2013 in JavaScript Mode

Hi!

I have a problem, maybe is a thing that I don't know or I don't control. I have my sketch in Java mode, and the sketch works correctly, but when I change to Javascript mode, the sketch, doesn't load the images. Every time I export the sketch, I copy the 'data' directory that contains the images inside the 'web-export' folder... but the sketch, doesnt work...

I'm using Processing 2.1 and Processing.js 1.4.1, this is my example...

// Global vars
/* @pjs preload="data/sky.jpg, data/cloud-icon.png"; */

PImage fondo, icono;
int i = 0;

void setup()
{
  size(1280, 720);
  colorMode(HSB, 100);
  smooth();

  fondo = loadImage("data/sky.jpg");
  icono = loadImage("data/cloud-icon.png");
}

void draw()
{
fondo(); //
nubes();
}

void nubes() {
  i = i+1;
  image(icono, i, 0);
}

void fondo() {
  image(fondo, 0, 0);  
}

I review in the introduccion of Processing.js that I must put the @pjs preload... but, I don't know if I need another thing or I'm doint anything wroing. Any suggestion? Thanks for your support.

Comments

  • loadImage() automatically loads the images from the data folder, so you don't need to specify it. Ie. remove the data/ part.

  • Thank you so much!

Sign In or Register to comment.