SurfaceをSpriteに貼ろう | Webプログラミング!

Time-stamp: "2013-10-25 Fri 09:14 JST hig"

Surfaceのサンプル1

Surfaceのサンプル1

surface1.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Test of Enchant.js</title>
    <style type="text/css">
      body { margin: 0; }
    </style>

    <script type="text/javascript" src="enchant.js"></script>
    <script type="text/javascript" src="plugins/ui.enchant.js"></script>
    <script type="text/javascript" src="surface1.js"></script>
  </head>
  <body>
  </body>
</html>

surface1.js

enchant();

window.onload = function() {
    var game = new Game(320,320);
    game.fps = 16;

    game.onload = function() {
	var suflag = new Surface(50,50);

	suflag.context.strokeStyle="rgb(50,100,150)";
	suflag.context.beginPath();
	suflag.context.moveTo(10,20);
	suflag.context.lineTo(30,40);
	suflag.context.stroke();

	var spflag = new Sprite(50,50);
	spflag.image=suflag;

	game.rootScene.addChild(spflag);
    };

    game.start();
};

このサイトのコンテンツ

QRcode to hig3.net

http://hig3.net