First batch of examples cleaned up

Mostly cosmetic improvements
This commit is contained in:
Anders Nissen 2014-02-12 23:23:44 +01:00
parent cb400573d4
commit fcd2033d40
8 changed files with 30 additions and 92 deletions

View file

@ -1,7 +1,6 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<!--<link href='http://fonts.googleapis.com/css?family=Snippet|Arvo:700italic|Podkova' rel='stylesheet' type='text/css'>-->
<title>pixi.js example 10 Text</title> <title>pixi.js example 10 Text</title>
<style> <style>
body { body {
@ -11,7 +10,6 @@
} }
</style> </style>
<script src="../../bin/pixi.dev.js"></script> <script src="../../bin/pixi.dev.js"></script>
</head> </head>
<body> <body>
@ -27,7 +25,6 @@
// do something // do something
init(); init();
} }
}; };
(function() { (function() {
var wf = document.createElement('script'); var wf = document.createElement('script');
@ -41,14 +38,14 @@
function runList(item) function runList(item)
{ {
console.log("_") console.log("_");
var safe = 0; var safe = 0;
var tmp = item; var tmp = item;
while(tmp._iNext) while(tmp._iNext)
{ {
safe++; safe++;
tmp = tmp._iNext; tmp = tmp._iNext;
console.log(tmp);//.childIndex); console.log(tmp);
if(safe > 100) if(safe > 100)
{ {
@ -68,15 +65,12 @@
// use callback // use callback
loader.onComplete = onAssetsLoaded; loader.onComplete = onAssetsLoaded;
// create an new instance of a pixi stage // create an new instance of a pixi stage
var stage = new PIXI.Stage(0x66FF99); var stage = new PIXI.Stage(0x66FF99);
// begin load // begin load
loader.load(); loader.load();
function onAssetsLoaded() function onAssetsLoaded()
{ {
var bitmapFontText = new PIXI.BitmapText("bitmap fonts are\n now supported!", {font: "35px Desyrel", align: "right"}); var bitmapFontText = new PIXI.BitmapText("bitmap fonts are\n now supported!", {font: "35px Desyrel", align: "right"});
@ -86,12 +80,8 @@
runList(bitmapFontText); runList(bitmapFontText);
stage.addChild(bitmapFontText); stage.addChild(bitmapFontText);
} }
// add a shiny background... // add a shiny background...
var background = PIXI.Sprite.fromImage("textDemoBG.jpg"); var background = PIXI.Sprite.fromImage("textDemoBG.jpg");
stage.addChild(background); stage.addChild(background);
@ -132,27 +122,8 @@
stage.removeAll(); stage.removeAll();
function animate() { function animate() {
// requestAnimFrame(animate);
// count++;
// if(count == 50)
// {
// count = 0;
// score++;
// // update the text...
// countingText.setText("COUNT 4EVAR: " + score);
// }
// // just for fun, let's rotate the text
// spinningText.rotation += 0.03;
// // render the stage
// renderer.render(stage);
} }
} }

View file

@ -10,7 +10,6 @@
} }
</style> </style>
<script src="../../bin/pixi.dev.js"></script> <script src="../../bin/pixi.dev.js"></script>
</head> </head>
<body> <body>
@ -82,7 +81,6 @@
// used for spinning! // used for spinning!
var count = 0; var count = 0;
requestAnimFrame(animate); requestAnimFrame(animate);
function animate() { function animate() {
@ -103,7 +101,6 @@
renderTexture = renderTexture2; renderTexture = renderTexture2;
renderTexture2 = temp; renderTexture2 = temp;
// set the new texture // set the new texture
outputSprite.setTexture(renderTexture); outputSprite.setTexture(renderTexture);

View file

@ -16,14 +16,11 @@
<body> <body>
<script> <script>
// create an new instance of a pixi stage // create an new instance of a pixi stage
var stage = new PIXI.Stage(0xFFFFFF, true); var stage = new PIXI.Stage(0xFFFFFF, true);
stage.setInteractive(true); stage.setInteractive(true);
var sprite = PIXI.Sprite.fromImage("spinObj_02.png");
var renderer = PIXI.autoDetectRenderer(620, 380); var renderer = PIXI.autoDetectRenderer(620, 380);
renderer.view.style.display = "block"; renderer.view.style.display = "block";
@ -33,7 +30,6 @@
var graphics = new PIXI.Graphics(); var graphics = new PIXI.Graphics();
// set a fill and line style // set a fill and line style
graphics.beginFill(0xFF3300); graphics.beginFill(0xFF3300);
graphics.lineStyle(10, 0xffd900, 1); graphics.lineStyle(10, 0xffd900, 1);
@ -74,7 +70,6 @@
graphics.moveTo(30,30); graphics.moveTo(30,30);
graphics.lineTo(600, 300); graphics.lineTo(600, 300);
stage.addChild(graphics); stage.addChild(graphics);
// let's create moving shape // let's create moving shape

View file

@ -109,7 +109,7 @@
logo.click = logo.tap = function() logo.click = logo.tap = function()
{ {
window.open("https://github.com/GoodBoyDigital/pixi.js", "_blank") window.open("https://github.com/GoodBoyDigital/pixi.js", "_blank");
} }
var help = new PIXI.Text("Click to turn masking on / off.", {font:"bold 12pt Arial", fill:"white"}); var help = new PIXI.Text("Click to turn masking on / off.", {font:"bold 12pt Arial", fill:"white"});
@ -120,7 +120,6 @@
requestAnimFrame(animate); requestAnimFrame(animate);
function animate() { function animate() {
bg.rotation += 0.01; bg.rotation += 0.01;
bgFront.rotation -= 0.01; bgFront.rotation -= 0.01;

View file

@ -34,7 +34,6 @@
0,0,1,0, 0,0,1,0,
0,0,0,1]; 0,0,0,1];
var filter = new PIXI.ColorMatrixFilter(); var filter = new PIXI.ColorMatrixFilter();
var container = new PIXI.DisplayObjectContainer(); var container = new PIXI.DisplayObjectContainer();
@ -61,13 +60,11 @@
panda.anchor.x = 0.5; panda.anchor.x = 0.5;
panda.anchor.y = 0.5; panda.anchor.y = 0.5;
container.addChild(panda); container.addChild(panda);
stage.addChild(container); stage.addChild(container);
// create a renderer instance // create a renderer instance
renderer.view.style.position = "absolute" renderer.view.style.position = "absolute"
renderer.view.style.width = window.innerWidth + "px"; renderer.view.style.width = window.innerWidth + "px";
renderer.view.style.height = window.innerHeight + "px"; renderer.view.style.height = window.innerHeight + "px";
@ -76,7 +73,6 @@
// add render view to DOM // add render view to DOM
document.body.appendChild(renderer.view); document.body.appendChild(renderer.view);
stage.filters = [filter]; stage.filters = [filter];
var count = 0; var count = 0;
@ -94,7 +90,6 @@
{ {
stage.filters = null; stage.filters = null;
} }
} }
/* /*
@ -119,11 +114,9 @@
help.position.x = 10; help.position.x = 10;
stage.addChild(help); stage.addChild(help);
requestAnimFrame(animate); requestAnimFrame(animate);
function animate() { function animate() {
bg.rotation += 0.01; bg.rotation += 0.01;
bgFront.rotation -= 0.01; bgFront.rotation -= 0.01;
@ -143,8 +136,6 @@
colorMatrix[6] = Math.sin(count / 4); colorMatrix[6] = Math.sin(count / 4);
filter.matrix = colorMatrix; filter.matrix = colorMatrix;
renderer.render(stage); renderer.render(stage);
requestAnimFrame( animate ); requestAnimFrame( animate );
} }

View file

@ -46,8 +46,6 @@
var pondFloorSprite = new PIXI.Sprite(pondFloorTexture); var pondFloorSprite = new PIXI.Sprite(pondFloorTexture);
stage.addChild(pondFloorSprite); stage.addChild(pondFloorSprite);
// create an array to store a refference to the dude in the pond // create an array to store a refference to the dude in the pond
var dudeArray = []; var dudeArray = [];
@ -55,7 +53,6 @@
for (var i = 0; i < totaldude; i++) for (var i = 0; i < totaldude; i++)
{ {
// create a new Sprite that uses the image name that we just generated as its source // create a new Sprite that uses the image name that we just generated as its source
var dude = PIXI.Sprite.fromImage("flowerTop.png"); var dude = PIXI.Sprite.fromImage("flowerTop.png");
@ -86,7 +83,6 @@
// finally we push the dude into the dudeArray so it it can be easily accessed later // finally we push the dude into the dudeArray so it it can be easily accessed later
dudeArray.push(dude); dudeArray.push(dude);
} }
// create a bounding box box for the little dudes // create a bounding box box for the little dudes
@ -97,7 +93,6 @@
viewWidth + dudeBoundsPadding * 2, viewWidth + dudeBoundsPadding * 2,
viewHeight + dudeBoundsPadding * 2); viewHeight + dudeBoundsPadding * 2);
var tick = 0; var tick = 0;
requestAnimationFrame(animate); requestAnimationFrame(animate);
@ -115,17 +110,15 @@
// wrap the dudes by testing there bounds.. // wrap the dudes by testing there bounds..
if (dude.position.x < dudeBounds.x)dude.position.x += dudeBounds.width; if (dude.position.x < dudeBounds.x)dude.position.x += dudeBounds.width;
else if(dude.position.x > dudeBounds.x + dudeBounds.width)dude.position.x -= dudeBounds.width else if (dude.position.x > dudeBounds.x + dudeBounds.width)dude.position.x -= dudeBounds.width;
if (dude.position.y < dudeBounds.y)dude.position.y += dudeBounds.height; if (dude.position.y < dudeBounds.y)dude.position.y += dudeBounds.height;
else if(dude.position.y > dudeBounds.y + dudeBounds.height)dude.position.y -= dudeBounds.height else if (dude.position.y > dudeBounds.y + dudeBounds.height)dude.position.y -= dudeBounds.height;
} }
// increment the ticker // increment the ticker
tick += 0.1; tick += 0.1;
// time to render the stage ! // time to render the stage !
renderer.render(stage); renderer.render(stage);

View file

@ -48,7 +48,6 @@
for (var i = 0; i < totalDudes; i++) for (var i = 0; i < totalDudes; i++)
{ {
// create a new Sprite that uses the image name that we just generated as its source // create a new Sprite that uses the image name that we just generated as its source
var dude = PIXI.Sprite.fromImage("eggHead.png"); var dude = PIXI.Sprite.fromImage("eggHead.png");
@ -80,7 +79,6 @@
// finally we push the dude into the dudeArray so it it can be easily accessed later // finally we push the dude into the dudeArray so it it can be easily accessed later
dudeArray.push(dude); dudeArray.push(dude);
} }
// create a bounding box box for the little dudes // create a bounding box box for the little dudes
@ -107,17 +105,15 @@
// wrap the dudes by testing their bounds.. // wrap the dudes by testing their bounds..
if (dude.position.x < dudeBounds.x)dude.position.x += dudeBounds.width; if (dude.position.x < dudeBounds.x)dude.position.x += dudeBounds.width;
else if(dude.position.x > dudeBounds.x + dudeBounds.width)dude.position.x -= dudeBounds.width else if (dude.position.x > dudeBounds.x + dudeBounds.width)dude.position.x -= dudeBounds.width;
if (dude.position.y < dudeBounds.y)dude.position.y += dudeBounds.height; if (dude.position.y < dudeBounds.y)dude.position.y += dudeBounds.height;
else if(dude.position.y > dudeBounds.y + dudeBounds.height)dude.position.y -= dudeBounds.height else if (dude.position.y > dudeBounds.y + dudeBounds.height)dude.position.y -= dudeBounds.height;
} }
// increment the ticker // increment the ticker
tick += 0.1; tick += 0.1;
// time to render the state! // time to render the state!
renderer.render(stage); renderer.render(stage);

View file

@ -67,7 +67,6 @@
* var texture = PIXI.Texture.fromFrame(frameName); * var texture = PIXI.Texture.fromFrame(frameName);
* var alien = new PIXI.Sprite(texture); * var alien = new PIXI.Sprite(texture);
*/ */
alien.position.x = Math.random() * 800 - 400; alien.position.x = Math.random() * 800 - 400;
alien.position.y = Math.random() * 600 - 300; alien.position.y = Math.random() * 600 - 300;
alien.anchor.x = 0.5; alien.anchor.x = 0.5;
@ -78,12 +77,9 @@
// start animating // start animating
requestAnimFrame(animate); requestAnimFrame(animate);
} }
function animate() { function animate() {
requestAnimFrame(animate); requestAnimFrame(animate);
// just for fun, lets rotate mr rabbit a little // just for fun, lets rotate mr rabbit a little