Even more clean-up

This commit is contained in:
Anders Nissen 2014-02-13 20:17:03 +01:00
parent 564f883640
commit 8a0036178e
13 changed files with 71 additions and 154 deletions

View file

@ -14,7 +14,6 @@
</head>
<body>
<script>
// Load them google fonts before starting...!
WebFontConfig = {
google: {
@ -49,8 +48,8 @@
if(safe > 100)
{
console.log("BREAK")
break
console.log("BREAK");
break;
}
}
}
@ -91,8 +90,6 @@
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);
requestAnimFrame(animate);
// create some white text using the Snippet webfont
var textSample = new PIXI.Text("Pixi.js can has\nmultiline text!", { font: "35px Snippet", fill: "white", align: "left" });
textSample.position.x = 20;
@ -125,6 +122,8 @@
function animate() {
}
requestAnimFrame(animate);
}
</script>

View file

@ -111,8 +111,6 @@
help.position.x = 10;
stage.addChild(help);
requestAnimFrame(animate);
function animate() {
bg.rotation += 0.01;
bgFront.rotation -= 0.01;
@ -136,6 +134,8 @@
renderer.render(stage);
requestAnimFrame(animate);
}
requestAnimFrame(animate);
</script>
</body>

View file

@ -16,7 +16,6 @@
</head>
<body>
<script>
var renderer = PIXI.autoDetectRenderer(630, 410);
renderer.view.style.position = "absolute"
renderer.view.style.width = window.innerWidth + "px";
@ -248,7 +247,6 @@
fish.rotation = -fish.direction - Math.PI/2;
// wrap..
if(fish.position.x < bounds.x)fish.position.x += bounds.width;
if(fish.position.x > bounds.x + bounds.width)fish.position.x -= bounds.width
@ -257,11 +255,11 @@
}
displacementFilter.offset.x = count * 10//blurAmount * 40;
displacementFilter.offset.y = count * 10
displacementFilter.offset.x = count * 10;
displacementFilter.offset.y = count * 10;
overlay.tilePosition.x = count * -10//blurAmount * 40;
overlay.tilePosition.y = count * -10
overlay.tilePosition.x = count * -10;
overlay.tilePosition.y = count * -10;
renderer.render(stage);
requestAnimFrame( animate );

View file

@ -17,8 +17,6 @@
height: 100%;
}
</style>
<script src="pixi.js"></script>
<script src="../../bin/pixi.js"></script>
</head>
@ -92,9 +90,6 @@
viewHeight + dudeBoundsPadding * 2);
var tick = 0;
requestAnimationFrame(animate);
function animate()
{
// iterate through the dudes and update the positions
@ -127,6 +122,7 @@
// request another animation frame...
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>

View file

@ -37,10 +37,10 @@
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0xFFFFFF);
var particles = new PIXI.SpriteBatch(PIXI.Texture.fromImage("eggHead.png"));
stage.addChild(particles);
var sprites = new PIXI.SpriteBatch();
stage.addChild(sprites);
var tints = [0XFFFFFF, 0XFFFBEE, 0XFFEEEE, 0XFADEED, 0XE8D4CD];
var tints = [0xFFFFFF, 0xFFFBEE, 0xFFEEEE, 0xFADEED, 0xE8D4CD];
// create an array to store a refference to the fish in the pond
var dudeArray = [];
@ -51,7 +51,7 @@
// create a new Sprite that uses the image name that we just generated as its source
var dude = PIXI.Sprite.fromImage("tinyMaggot.png");
dude.tint = Math.random() * 0XE8D4CD;
dude.tint = Math.random() * 0xE8D4CD;
// set the anchor point so the the dude texture is centerd on the sprite
dude.anchor.x = dude.anchor.y = 0.5;
@ -80,7 +80,7 @@
// finally we push the dude into the dudeArray so it it can be easily accessed later
dudeArray.push(dude);
particles.addChild(dude);
sprites.addChild(dude);
}
// create a bounding box box for the little dudes
@ -91,8 +91,6 @@
viewHeight + dudeBoundsPadding * 2);
var tick = 0;
requestAnimationFrame(animate);
function animate()
{
// iterate through the dude and update the position
@ -126,6 +124,8 @@
// request another animation frame..
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>

View file

@ -95,7 +95,6 @@
requestAnimFrame(animate);
}
</script>
</body>

View file

@ -50,21 +50,18 @@
explosionTextures.push(texture);
};
// create a texture from an image path
// add a bunch of aliens
for (var i = 0; i < 50; i++)
{
// create an explosion MovieClip
var explosion = new PIXI.MovieClip(explosionTextures);
explosion.position.x = Math.random() * 800;
explosion.position.y = Math.random() * 600;
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.scale.x = explosion.scale.y = 0.75 + Math.random() * 0.5;
explosion.gotoAndPlay(Math.random() * 27);
@ -73,17 +70,13 @@
// start animating
requestAnimFrame( animate );
}
function animate() {
renderer.render(stage);
requestAnimFrame(animate);
renderer.render(stage);
}
</script>
</body>

View file

@ -16,7 +16,6 @@
<div id="sx">SX: 0<br />SY: 0</div>
<script>
$(window).resize(resize)
window.onorientationchange = resize;
@ -31,14 +30,13 @@
var slideX = w / 2;
var slideY = h / 2;
var stars = [];
var renderer;
var stage;
function start() {
var ballTexture = new PIXI.Texture.fromImage("assets/bubble_32x32.png");
renderer = PIXI.autoDetectRenderer(w, h);
stage = new PIXI.Stage;
stage = new PIXI.Stage();
document.body.appendChild(renderer.view);
@ -62,15 +60,12 @@
resize();
requestAnimFrame(update);
}
function newWave () {
sx = 1.0 + (Math.random() / 20);
sy = 1.0 + (Math.random() / 20);
document.getElementById('sx').innerHTML = 'SX: ' + sx + '<br />SY: ' + sy;
}
function resize()
@ -116,7 +111,6 @@
requestAnimFrame(update);
}
</script>
</body>

View file

@ -14,7 +14,6 @@
<a href="http://www.html5gamedevs.com/topic/59-pixijs-has-landed/"><img src="assets/pixi.png" width="56" height="22" id="pixi" title="pixi.js" /></a>
<script>
$(window).resize(resize)
window.onorientationchange = resize;
@ -37,13 +36,12 @@
var tpoint2 = [];
var tpoint3 = [];
var balls = [];
var renderer;
var stage;
function start() {
var ballTexture = new PIXI.Texture.fromImage("assets/pixel.png");
renderer = PIXI.autoDetectRenderer(w, h);
stage = new PIXI.Stage;
document.body.appendChild(renderer.view);
@ -70,32 +68,25 @@
setTimeout(nextObject, 5000);
requestAnimFrame(update);
}
function nextObject() {
current++;
if (current > objs)
{
current = 0;
}
makeObject(current);
setTimeout(nextObject, 8000);
}
function makeObject(t) {
var xd;
switch (t)
{
case 0:
for (var i = 0; i < n; i++)
{
points1[i] = -50 + Math.round(Math.random() * 100);
@ -103,9 +94,7 @@
points3[i] = 0;
}
break;
case 1:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -114,9 +103,7 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 2:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -125,7 +112,6 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 3:
for (var i = 0; i < n; i++)
@ -136,7 +122,6 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 4:
for (var i = 0; i < n; i++)
@ -147,7 +132,6 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 5:
for (var i = 0; i < n; i++)
@ -158,7 +142,6 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 6:
for (var i = 0; i < n; i++)
@ -169,7 +152,6 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 7:
for (var i = 0; i < n; i++)
@ -180,7 +162,6 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 8:
for (var i = 0; i < n; i++)
@ -191,7 +172,6 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 9:
for (var i = 0; i < n; i++)
@ -202,9 +182,7 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 10:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -213,9 +191,7 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 11:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -224,9 +200,7 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 12:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -235,9 +209,7 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 13:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -246,9 +218,7 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 14:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -257,9 +227,7 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 15:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -268,9 +236,7 @@
points3[i] = Math.sin(i * 360 / n) * 100;
}
break;
case 16:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -279,9 +245,7 @@
points3[i] = Math.sin(xd) * 100;
}
break;
case 17:
for (var i = 0; i < n; i++)
{
xd = -90 + Math.round(Math.random() * 180);
@ -291,7 +255,6 @@
}
break;
}
}
function resize()
@ -338,14 +301,12 @@
balls[i].position.x = (512 * tx) / (d - tz) + w / 2;
balls[i].position.y = (h/2) - (512 * ty) / (d - tz);
}
renderer.render(stage);
requestAnimFrame(update);
}
</script>
</body>

View file

@ -22,7 +22,6 @@
</head>
<body>
<script>
// create an new instance of a pixi stage
// the second parameter is interactivity...
var interactive = true;
@ -72,11 +71,10 @@
// set the mousedown and touchstart callback..
button.mousedown = button.touchstart = function(data) {
this.isdown = true;
this.setTexture(textureButtonDown);
this.alpha = 1;
}
};
// set the mouseup and touchend callback..
button.mouseup = button.touchend = button.mouseupoutside = button.touchendoutside = function(data) {
@ -90,36 +88,35 @@
{
this.setTexture(textureButton);
}
}
};
// set the mouseover callback..
button.mouseover = function(data) {
this.isOver = true;
if(this.isdown)return
if (this.isdown)
return;
this.setTexture(textureButtonOver)
}
this.setTexture(textureButtonOver);
};
// set the mouseout callback..
button.mouseout = function(data) {
this.isOver = false;
if(this.isdown)return
if (this.isdown)
return
this.setTexture(textureButton)
}
};
button.click = function(data) {
console.log("CLICK!");
}
};
button.tap = function(data) {
console.log("TAP!!");
}
};
// add it to the stage
stage.addChild(button);
@ -129,26 +126,20 @@
};
// set some silly values...
buttons[0].scale.x = 1.2;
buttons[1].scale.y = 1.2;
buttons[2].rotation = Math.PI / 10;
buttons[3].scale.x = 0.8;
buttons[3].scale.y = 0.8;
buttons[4].scale.x = 0.8;
buttons[4].scale.y = 1.2;
buttons[4].rotation = Math.PI;
function animate() {
requestAnimFrame(animate);
// render the stage
renderer.render(stage);
requestAnimFrame(animate);
}
// add a logo!
@ -160,13 +151,9 @@
pixiLogo.position.x = 620 - 56;
pixiLogo.position.y = 400 - 32;
pixiLogo.setInteractive(true);
pixiLogo.click = pixiLogo.tap = function() {
var win=window.open("http://www.pixijs.com", '_blank');
}
window.open("http://www.pixijs.com", '_blank');
};
</script>
</body>

View file

@ -26,12 +26,10 @@
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</div>
<script>
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x66FF99);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(400, 300,false,true);
// add the renderer view element to the DOM
@ -40,10 +38,9 @@
renderer.view.style.top = "0px";
renderer.view.style.left = "0px";
requestAnimFrame(animate);
// create a texture from an image path
var texture = PIXI.Texture.fromImage("bunny.png");
// create a new Sprite using the texture
var bunny = new PIXI.Sprite(texture);
@ -58,7 +55,6 @@
stage.addChild(bunny);
function animate() {
requestAnimFrame(animate);
// just for fun, lets rotate mr rabbit a little
@ -68,6 +64,7 @@
renderer.render(stage);
}
requestAnimFrame(animate);
</script>
</body>

View file

@ -14,9 +14,8 @@
</head>
<body>
<script>
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x97c56e, true);
var stage = new PIXI.Stage(0x97C56E, true);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight, null);

View file

@ -7,27 +7,23 @@
margin: 0;
padding: 0;
background-color: #FFFFFF;
}
</style>
<script src="../../bin/pixi.dev.js"></script>
</head>
<body>
<script>
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x97c56e, true);
var stage = new PIXI.Stage(0x97C56E, true);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight, null);
var renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight);
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);
renderer.view.style.position = "absolute";
renderer.view.style.top = "0px";
renderer.view.style.left = "0px";
requestAnimFrame(animate);
document.body.appendChild(renderer.view);
// create a texture from an image path
var texture = PIXI.Texture.fromImage("p2.jpeg");
@ -35,16 +31,11 @@
// create a tiling sprite ...
// requires a texture, width and height
// to work in webGL the texture size must be a power of two
var tilingSprite = new PIXI.TilingSprite(texture, window.innerWidth, window.innerHeight)
var count = 0;
var tilingSprite = new PIXI.TilingSprite(texture, window.innerWidth, window.innerHeight);
stage.addChild(tilingSprite);
var count = 0;
function animate() {
requestAnimFrame(animate);
count += 0.005;
tilingSprite.tileScale.x = 2 + Math.sin(count);
@ -55,8 +46,11 @@
// render the stage
renderer.render(stage);
requestAnimFrame(animate);
}
requestAnimFrame(animate);
</script>
</body>