Aller au contenu

Bloc évanescent

Fanny

Les blocs évanescents n’aparaissent que lorsqu’un personnage s’en rapproche.

  1. load.js
    const PNG = [
    'invisible',
    'grass',
    ];
  2. config.js
    const TILE_CONFIG = {
    // text
    '*': () => [
    sprite('invisible'),
    area(),
    body({ isStatic: true }),
    offscreen(),
    vanishing(),
    sight({
    sight: 260,
    liveUpdate: true,
    offset: vec2(32, 32),
    }),
    opacity(),
    ],
    // player
    '#': () => [
    sprite('bean'),
    platformerController(),
    jumpController(),
    sleep(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    body(),
    respawn(),
    falling(),
    rotate(),
    pos(0, -20),
    anchor('center'),
    'player',
    ],
    // block
    '=': () => [
    sprite('grass-tileset'),
    offscreen({ hide: true }),
    tile({ isObstacle: true }),
    autoTiling(),
    area(),
    body({ isStatic: true }),
    ],
    };
  3. level.js
    const LEVELS = [
    {
    map: `
    *
    **
    ***
    **
    ***
    #
    *****
    `,
    },
    ]
vanishing()
example
config.js
vanishing({
tag: 'player',
delay: 0.2,
on: true
}),
sight()
example
config.js
sight({
sight: 180,
looseSight: 340,
raycast: false,
tag: 'player',
rayCastExclude: ['pass through'],
offset: vec2(0, 0),
on: true,
offScreenPaused: false,
liveUpdate: false,
onAddOnly: false
}),