Преглед изворни кода

started upgrading to pixijs 4.5

tags/v0.1.4^2
Shaun пре 7 година
родитељ
комит
d1d9bf8f6e
9 измењених фајлова са 163 додато и 33 уклоњено
  1. BIN
     
  2. BIN
     
  3. BIN
     
  4. +5
    -5
      src/client/js/components/stats.js
  5. +6
    -3
      src/client/js/rendering/particles.js
  6. +33
    -10
      src/client/js/rendering/renderer.js
  7. +21
    -10
      src/client/plugins/pixi.min.js
  8. +41
    -5
      src/server/config/maps/cave/map.json
  9. +57
    -0
      src/server/config/maps/cave/zone.js



+ 5
- 5
src/client/js/components/stats.js Прегледај датотеку

@@ -30,16 +30,16 @@ define([
layerName: 'effects',
x: 0,
y: 0,
w: 0,
h: 0,
w: 1,
h: 1,
color: 0x802343
});

renderer.buildRectangle({
x: 0,
y: 0,
w: 0,
h: 0,
w: 1,
h: 1,
parent: this.hpSprite,
color: 0xd43346
});
@@ -73,7 +73,7 @@ define([
h: 5
});

this.hpSprite.visible = (this.values.hp < this.values.hpMax);
this.hpSprite.visible = true;//(this.values.hp < this.values.hpMax);
},

extend: function(blueprint) {


+ 6
- 3
src/client/js/rendering/particles.js Прегледај датотеку

@@ -1,9 +1,11 @@
define([
'particles',
'js/rendering/particleDefaults'
'js/rendering/particleDefaults',
'js/rendering/shaders/outline'
], function(
pixiParticles,
particleDefaults
particleDefaults,
shaderOutline
) {
return {
renderer: null,
@@ -14,6 +16,7 @@ define([
lastTick: null,

init: function(options) {
this.r = options.r;
this.renderer = options.renderer;
this.stage = options.stage;
this.lastTick = Date.now();
@@ -22,7 +25,7 @@ define([
buildEmitter: function(config) {
var options = $.extend(true, {}, particleDefaults, config);

var emitter = new PIXI.particles.Emitter(this.stage, ['images/particles.png'], options);
var emitter = new PIXI.particles.Emitter(this.r.layers.tileSprites, ['images/particles.png'], options);
emitter.emit = true;

this.emitters.push(emitter);


+ 33
- 10
src/client/js/rendering/renderer.js Прегледај датотеку

@@ -82,7 +82,7 @@ define([
this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;

this.renderer = pixi.autoDetectRenderer(this.width, this.height, {
backgroundColor: 0x2d2136
backgroundColor: '0x2d2136'
});

window.onresize = this.onResize.bind(this);
@@ -115,8 +115,9 @@ define([
}, this);

particles.init({
r: this,
renderer: this.renderer,
stage: this.layers.particles
stage: this.layers.tileSprites
});

this.buildSpritesTexture();
@@ -140,7 +141,6 @@ define([
}, this);

var renderTexture = pixi.RenderTexture.create(this.textures.tiles.width, totalHeight);
console.log(renderTexture);
this.renderer.render(container, renderTexture);

this.textures.sprites = renderTexture;
@@ -344,9 +344,6 @@ define([
var alpha = tileOpacity.map(c);
var canFlip = tileOpacity.canFlip(c);

if (c == 536870624)
console.log(i, j);

var tile = new pixi.Sprite(this.getTexture('sprites', c));

tile.alpha = alpha;
@@ -639,14 +636,18 @@ define([

graphics.beginFill(obj.color || '0x48edff', fillAlpha);

graphics.pivot = new pixi.Point(0, 0);

if (obj.strokeColor)
graphics.lineStyle(scaleMult, obj.strokeColor);

graphics.moveTo(obj.x, obj.y);
graphics.drawRect(obj.x, obj.y, obj.w, obj.h);

/*graphics.moveTo(obj.x, obj.y);
graphics.lineTo(obj.x + obj.w, obj.y);
graphics.lineTo(obj.x + obj.w, obj.y + obj.h);
graphics.lineTo(obj.x, obj.y + obj.h);
graphics.lineTo(obj.x, obj.y);
graphics.lineTo(obj.x, obj.y);*/

graphics.endFill();

@@ -656,11 +657,33 @@ define([
},

moveRectangle(obj) {
obj.sprite.position = new pixi.Point(obj.x, obj.y);
obj.sprite.width = obj.w;
obj.sprite.height = obj.h;
return;

var points = obj.sprite.graphicsData[0].shape.points;
if (!points)
return;

obj.sprite.dirty = true;
graphics.clear();

graphics.beginFill(obj.color || '0x48edff', fillAlpha);

if (obj.strokeColor)
graphics.lineStyle(scaleMult, obj.strokeColor);

graphics.drawRect(obj.x, obj.y, obj.w, obj.h);

/*graphics.moveTo(obj.x, obj.y);
graphics.lineTo(obj.x + obj.w, obj.y);
graphics.lineTo(obj.x + obj.w, obj.y + obj.h);
graphics.lineTo(obj.x, obj.y + obj.h);
graphics.lineTo(obj.x, obj.y);*/

graphics.endFill();

/*obj.sprite.dirty = true;
obj.sprite.clearDirty = true;

points[0] = obj.x;
@@ -672,7 +695,7 @@ define([
points[6] = obj.x;
points[7] = obj.y + obj.h;
points[8] = obj.x;
points[9] = obj.y;
points[9] = obj.y;*/
},

buildObject: function(obj) {


+ 21
- 10
src/client/plugins/pixi.min.js
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 41
- 5
src/server/config/maps/cave/map.json
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 57
- 0
src/server/config/maps/cave/zone.js Прегледај датотеку

@@ -344,6 +344,63 @@ module.exports = {
}
}
},
sunlight: {
components: {
cpnParticles: {
simplify: function() {
return {
type: 'particles',
blueprint: {
color: {
start: ['ffeb38', 'ffeb38'],
end: ['ffeb38', 'ffeb38']
},
scale: {
start: {
min: 40,
max: 120
},
end: {
min: 20,
max: 80
}
},
speed: {
start: {
min: 0,
max: 2
},
end: {
min: 0,
max: 0
}
},
lifetime: {
min: 12,
max: 40
},
alpha: {
start: 0.1,
end: 0
},
randomScale: true,
randomSpeed: true,
chance: 0.02,
randomColor: true,
spawnType: 'rect',
blendMode: 'overlay',
spawnRect: {
x: -80,
y: -80,
w: 160,
h: 160
}
}
}
}
}
}
},
bubbles: {
components: {
cpnParticles: {


Loading…
Откажи
Сачувај