wheelController
Arthur
Charger un atlas images
Section intitulée « Charger un atlas images »load.js function loadAtlas() {loadSpriteAtlas('assets/sprites/face-atlas.png', {face: {x: 0,y: 0,width: 196,height: 53,sliceX: 4,anims: {idle: { from: 0, to: 0 },run: { from: 0, to: 0 },sleep: { from: 1, to: 1 },jump: { from: 2, to: 2 },worry: { from: 3, to: 3 },},},});loadSpriteAtlas("assets/sprites/bean-atlas.png", {"bean": {x: 0, y: 0,width: 244, height: 53,sliceX: 4,anims: {idle: { from: 0, to: 0 },run: { from: 0, to: 0 },sleep: { from: 1, to: 1 },jump: { from: 2, to: 2 },worry: { from: 3, to: 3 },},},})loadSpriteAtlas("assets/sprites/splash.png", {"splash": {x: 0, y: 0,width: 384, height: 64,sliceX: 6,anims: { explode: { from: 0, to: 5, speed:30 } },},})}Déclarer un objet
Section intitulée « Déclarer un objet »config.js const TILE_CONFIG = {// player 1O: () => [wheelController(),wheelSprite(),jumpController({ wheelRollToJump: true }),sprite('face'),sleep(),alive(),opacity(),scale(),health(1, 4),area(),body(),respawn(),falling(),rotate(),pos(0, -20),anchor('center'),'player',],// 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 }),],};Placer les objets
Section intitulée « Placer les objets »level.js const LEVELS = [{map: `======= ===========O =============`,},]
Paramètres
Section intitulée « Paramètres »wheelController()
exampleconfig.js
wheelController({ moveSpeed: 480, acceleration: 0.1, speedDelay: 0.1}),jumpController()
exampleconfig.js
jumpController({ jumpKey: ['up', 'space'], keyPressToJump: true, mousePressToJump: false, wheelRollToJump: false, jumpForce: 1000, airjumpForce: 800, doubleJump: 0, rollJumpDelay: 0.2}),wheelSprite()
exampleconfig.js
wheelSprite({ animRollSpeed: 1000, sprite: 'greenpea', offset: vec2(0, 0), spriteParam: {}, z: -1}),