Вход Регистрация
Файл: apwa/8march/butterfly-init.js
Строк: 101
<?php
var canvas;
        var 
stage;

        var 
bfimgsrc = [{ left"8march/images/Didius 1.png"right"8march/images/Didius 2.png" },
        { 
left"8march/images/Amphitrion 1.png"right"8march/images/Amphitrion 2.png" },
        { 
left"8march/images/Catenarius 1.png"right"8march/images/Catenarius 2.png" },
        { 
left"8march/images/Cyanides 1.png"right"8march/images/Cyanides 2.png" },
        { 
left"8march/images/Cypres 1.png"right"8march/images/Cypres 2.png" },
        { 
left"8march/images/Diana 1.png"right"8march/images/Diana 2.png" },
        { 
left"8march/images/Hecuba 1.png"right"8march/images/Hecuba 2.png" },
        { 
left"8march/images/Peleides 1.png"right"8march/images/Peleides 2.png" },
        { 
left"8march/images/Polyphemus 1.png"right"8march/images/Polyphemus 2.png" },
        { 
left"8march/images/Sulkowski 1.png"right"8march/images/Sulkowski 2.png"}];

        var 
bfsimages = [];
        var 
bfs = [];

        function 
init8() {
            
// create a new stage and point it at our canvas:
            
canvas document.getElementById("canvas");
            
stage = new Stage(canvas);
            
stage.enableMouseOver(10);

            
loadButterflyis(8);

            
canvas.onclick = function(){
                
loadButterflyis(1);
            };

            
// subscribe to Ticker
            
Ticker.addListener(window);
        }
        
        function 
loadButterflyis(count) {
            for (var 
0countk++) 
            {
                var 
Math.floor(bfimgsrc.length Math.random());

                var 
bfimages = {
                    
left: new Image(),
                    
right: new Image(),
                    
loadedWings0,
                    
onreadyonButterflyImagesReady
                
};

                
// loading left wing
                
bfimages.left.src bfimgsrc[i].left;
                
bfimages.left.onload onWingImageLoaded;
                
bfimages.left.butterfly bfimages;

                
// loading right wing
                
bfimages.right.src bfimgsrc[i].right;
                
bfimages.right.onload onWingImageLoaded;
                
bfimages.right.butterfly bfimages;
            }
        }

        function 
onWingImageLoaded(event) {
            var 
image event.target;
            
image.butterfly.loadedWings++;
            if (
image.butterfly.loadedWings == 2)
                
image.butterfly.onready(image.butterfly);
        }

        function 
onButterflyImagesReady(butterflyImgs) {
            
// create a new butterfly
            
var butterfly = new Butterfly(butterflyImgs.leftbutterflyImgs.right);
            
            
// add butterfly to stage
            
stage.addChild(butterfly);

            
// change batterfly position
            
butterfly.canvas.width Math.random() | 0;
            
butterfly.canvas.height Math.random() | 0;
            
            if(
butterfly.33) {butterfly.34;}
            if(
butterfly.canvas.width 33) {butterfly.canvas.width 34;}
            if(
butterfly.52) {butterfly.53;}
            if(
butterfly.canvas.height 52) {butterfly.canvas.height 53;}

            
bfs.push(butterfly);            
        }

        
// update scene on each tick
        
function tick() {
            for (var 
0bfs.lengthi++) {
                var 
butterfly bfs[i];
                if (
butterfly.isActive()) 
                {
                    
butterfly.move();
                } 
                else if (
Math.random() > 0.999
                {
                    
butterfly.reset();
                }
            }
            
stage.update();
        }
?>
Онлайн: 2
Реклама