Convert LiveSampleBasic.html into two separate files *.html and *.js

40 views
Skip to first unread message

vmars316

unread,
Apr 17, 2013, 9:59:07 PM4/17/13
to enchantjs-...@googlegroups.com
Helo & Thanks ,
In the code below: 
How can I convert this "LiveSampleBasic.html". Html file (below) 
into two separate files:
"LiveSampleBasic.html"  and  "LiveSampleBasic.js"  ?

I don't understand where does the  window.onload  statement go ? 

<! Doctype html>
<-! LiveSampleBasic.html ->
<html> <head> <script src="enchant.js"> </ script> </ head>
<body style="margin:0; padding: 0;">
<script>
    enchant (); / / initialize
    var game = new Game (320, 320); / / game stage
    game.preload ('chara1.png'); / / preload image
    game.fps = 20;

    game.onload = function () {
        var bear = new Sprite (32, 32);
        bear.image = game.assets ['chara1.png'];
        game.rootScene.addChild (bear);
        bear.frame = [6, 6, 7, 7]; / / select sprite frame
        
        bear.tl.moveBy (288, 0, 90) / / move right
            . ScaleTo (-1, 1, 10) / / turn left
            . MoveBy (-288, 0, 90) / / move left
            . ScaleTo (1, 1, 10) / / turn right
            . Loop (); / / loop it
    };

    game.start (); / / start your game!
</ Script>
</ Body>
</ Html>

sidestepism

unread,
Apr 18, 2013, 7:13:32 AM4/18/13
to enchantjs-...@googlegroups.com

Hi!

<script src="livesample-basic.js"></script>
This will include external js file.

It works if you put <script> tag on the bottom of <body> content.
If you want to put <script> in head, just wrap all the script with window.onload = function(){ ... }

You can see, fork, download a simple example project here:
http://code.9leap.net/codes/show/28472

-----------
sidestepism

vmars316

unread,
Apr 20, 2013, 7:10:21 PM4/20/13
to enchantjs-...@googlegroups.com
Ok, I see..Thanks..vm
Reply all
Reply to author
Forward
0 new messages