Example 3 updated

This commit is contained in:
Mat Groves 2013-08-18 19:13:57 +01:00
parent bc3c8efe10
commit c74c608e38

View file

@ -10,9 +10,6 @@
}
</style>
<script src="pixi.js"></script>
<script src="../../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
</head>
<body>
<script>
@ -29,24 +26,18 @@
//begin load
loader.load();
// holder to store aliens
var explosions = [];
var count = 0;
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0xFF0000, true);;
var stage = new PIXI.Stage(0xFFFFFF);;
// create a renderer instance.
// renderer = new PIXI.CanvasRenderer(800, 600);
renderer = PIXI.autoDetectRenderer(800, 600);
var graphics = new PIXI.Graphics();
graphics.beginFill(0x0000FF, 1);
graphics.drawRect(0, 0, 800, 600);
stage.addChild(graphics);
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);
@ -61,102 +52,37 @@
explosionTextures.push(texture);
};
expl = [];
container = new PIXI.DisplayObjectContainer();
//container.addFilter();
stage.addChild(container);
// create a texture from an image path
// add a bunch of aliens
for (var i = 0; i < 5; i++)
for (var i = 0; i < 50; i++)
{
// create an explosion MovieClip
var explosion = new PIXI.MovieClip(explosionTextures);
explosion.position.x = i * 200;//Math.random() * 800;
explosion.position.x = Math.random() * 800;
explosion.position.y = Math.random() * 600;
explosion.pivot.x = 100;// 0.5;
explosion.pivot.y = 100;//0.5;
explosion.anchor.x = 0.5;
explosion.anchor.y = 0.5;
explosion.rotation = Math.random() * Math.PI;
explosion.scale.x = explosion.scale.y = 0.75 + Math.random() * 0.5
explosion.gotoAndPlay(Math.random() * 27);
explosion.interactive = true;
if(i<2)
{
container.addChild(explosion);
}
else
{
stage.addChild(explosion);
}
expl.push(explosion);
explosion.click = function()
{
if(!graphics.filter)
{
graphics.addFilter();
}
else
{
graphics.removeFilter();
}
// this.parent.addChildAt(this, 4);
onRemove();
}
if(i == 0)
{
//runList(container);
}
stage.addChild(explosion);
}
stage.addChildAt(graphics, 2);
// start animating
requestAnimFrame( animate );
runList(stage)
}
function runList(item)
{
console.log(">>>>>>>>>")
console.log("_")
var safe = 0;
var tmp = item.first;
console.log(tmp);
while(tmp._iNext)
{
safe++;
// console.log(tmp.childIndex + tmp);
tmp = tmp._iNext;
console.log(tmp);//.childIndex);
// console.log(tmp);
if(safe > 100)
{
console.log("BREAK")
break
}
}
}
function onRemove()
{
runList(stage)
}
function animate() {
requestAnimFrame( animate );
for (var i=0; i < expl.length; i++) {
// expl[i].rotation += 0.3;
};
renderer.render(stage);
}