è‹«°ç‰§é«°‚...

Download è‹«°ç‰§é«°‚ ‚½ƒ•ƒˆ‚¦‚§‚¢ƒ†‚¯ƒƒ­‚¸ƒ¼éƒ¨  §‚²ƒ¼ƒ ½œ‚ 3

Post on 19-Jul-2015

76 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

  • 1 enchant.js

    (3)2015/05/12

  • bear.x 320bear.x0

  • if

    if () { ; }

  • bearX320 0

    enchant();

    window.onload = function() { var core = new Core(320, 320); core.preload('chara1.png');

    core.onload = function() { var bear = new Sprite(32, 32); bear.image = core.assets['chara1.png']; bear.x = 0; bear.y = 0;

    core.rootScene.addChild(bear);

    bear.addEventListener('enterframe', function() { this.x += 3; if (this.x > 320) { this.x = 0; } }); } core.start(); }

  • if

    if (this.x > 320) { this.x = 0; }

    this.x 320

    this.x 0

  • (1)

  • main.jsenchant();

    window.onload = function() { var core = new Core(320, 320); core.preload('chara1.png');

    core.onload = function() { var bear = new Sprite(32, 32); bear.image = core.assets['chara1.png']; bear.x = 0; bear.y = 0;

    core.rootScene.addChild(bear);

    bear.addEventListener('enterframe', function() { this.x += 3; this.frame = this.age % 3;

    if (this.x > 320) { this.x = 0; } }); } core.start(); }

    this.frame = this.age % 3;

  • chara1.png

  • chara1.png

    var bear = new Sprite(32, 32); // 32px OK

  • chara1.png

    var bear = new Sprite(32, 50); //

  • (2)

  • main.js

    // bear.addEventListener('enterframe', function() { this.frame = this.age % 3; if (core.input.left) { this.x -= 3; } if (core.input.right) { this.x += 3; } if (core.input.up) { this.y -= 3; } if (core.input.down) { this.y += 3; } }); //

  • main.js

    if

    if (core.input.left) { this.x -= 3; }

    XY

  • enchant();

    window.onload = function() { var core = new Core(320, 320); core.preload('chara1.png');

    core.onload = function() { var bear = new Sprite(32, 32); bear.image = core.assets['chara1.png']; bear.x = 0; bear.y = 0;

    core.rootScene.addChild(bear); } core.start(); }

    enchant();

    window.onload = function() { var core = new Core(320, 320); core.preload('chara1.png');

    core.onload = function() { var bear = new Sprite(32, 32); bear.image = core.assets['chara1.png']; bear.x = 0; bear.y = 0;

    core.rootScene.addChild(bear); } core.start(); }

  • [tab]

    3

  • TeraPad

    PCTeraPadSublimeText

  • (1)

  • main.js // if (core.input.down) { this.y += 3; } });

    var label = new Label(); label.x = 280; label.y = 5; label.color = 'red'; label.font = '14px "Arial"'; label.text = '0';

    label.on('enterframe', function() { label.text = core.frame / core.fps; });

    core.rootScene.addChild(bear); core.rootScene.addChild(label); } core.start(); }

  • main.js // if (core.input.down) { this.y += 3; } });

    var label = new Label(); label.x = 280; label.y = 5; label.color = 'red'; label.font = '14px "Arial"'; label.text = '0';

    label.on('enterframe', function() { label.text = core.frame / core.fps; });

    core.rootScene.addChild(bear); core.rootScene.addChild(label); } core.start(); }

    label

    addChild

    addEventListener

  • label.on

    label.on('enterframe', function() { label.text = core.frame / core.fps; });

    addEventListener

    label.text label core.frame / core.fps

    fps

  • 11.

    2. 5 / 2;#=> 2.5 Math.floor(5 / 2); #=> 2

  • (2)

  • enchant();

    window.onload = function() { var core = new Core(320, 320); core.preload('chara1.png');

    core.onload = function() { var bear = new Sprite(32, 32); bear.image = core.assets['chara1.png']; bear.x = 0; bear.y = 0;

    var enemy = new Sprite(32, 32); enemy.image = core.assets['chara1.png']; enemy.x = 280; enemy.y = 50; enemy.frame = 5;

    bear.addEventListener('enterframe', function() { // addChild

    5

  • // if (core.input.down) { this.y += 3; }

    if (this.within(enemy, 15)) { label.text = 'HIT!'; } });

    var label = new Label(); label.x = 280; label.y = 5; label.color = 'red'; label.font = '14px "Arial"'; label.text = '0';

    label.on('enterframe', function() { label.text = core.frame / core.fps; }); //

    label.text HIT!

  • within

    if (this.within(enemy, 15)) { label.text = 'HIT!'; }

    thisbear

    this.within(enemy, 15)thisenemy15pxHIT!

  • 21.

    2. framexy 2

View more