Asset invalide

Le problème exposé dans ce sujet a été résolu.

Bonjour,

J'ai l'architecture suivante :

1
2
3
4
5
6
7
8
simulation
  page.html
  simu-quintus.js
  style.css
  images/
    tree.png (60*30px)
  data/
    tileset.json

Et le code suivant :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
window.addEventListener('load', function() {
  var RAMP_LEN = 20,
      TRACTOR_W = 40,
      TRACTOR_H = 20;

  // Setup
  var Q = new Quintus();

  Q.include([
    Quintus.Sprites,
    Quintus.Scenes,
    Quintus.Anim,
    Quintus['2D'],
    Quintus.Input
  ]);

  Q.setup('canvas', {
    width: 510,
    height: 450
  });

  Q.controls();

  // Sprites
  Q.Sprite.extend('Tractor', {
    draw: function(ctx) {
      // Tractor
      ctx.lineWidth = "2";
      ctx.strokeRect(this.p.x, this.p.y, this.p.w, this.p.h);

      // Ramp
      ctx.beginPath();
      ctx.moveTo(this.p.x + this.p.w/2, this.p.y);
      ctx.lineTo(this.p.x + this.p.w/2, this.p.y - RAMP_LEN);
      ctx.stroke();
    }
  });

  // 2D
  Q.sheet('tiles', 'tree.png', { tileW: 30, tileH: 30 });

  // Scene
  Q.scene('scene', function(scene) {
    var tractor = new Q.Tractor({x: 30, y: 100, w: TRACTOR_W, h: TRACTOR_H});

    var tiles = new Q.TileLayer({
      dataAsset: 'tileset.json',
      sheet: 'tiles',
      tileW: Q.sheets['tiles'].tileW,
      tileH: Q.sheets['tiles'].tileH
    });

    scene.insert(tractor);
    scene.collisionLayer(tiles);
  });

  Q.load(['tree.png', 'tileset.json'], function() {
    Q.stageScene('scene', 0);
  });
});

Mon tileset :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
]

Quand j'ouvre ma page HTML, j'obtiens en console : uncaught exception: Invalid Asset:tree.png.

Merci. :)

+0 -0
Connectez-vous pour pouvoir poster un message.
Connexion

Pas encore membre ?

Créez un compte en une minute pour profiter pleinement de toutes les fonctionnalités de Zeste de Savoir. Ici, tout est gratuit et sans publicité.
Créer un compte