Closed jonlepage closed 6 years ago
how we supose to deal with somthing like thats . I do not want documentation comparable to Unity with here super doc on C# but these difficult to understand what happens here OMG!
var PIXI;
(function (PIXI) {
var tilemap;
(function (tilemap_1) {
var ZLayer = (function (_super) {
__extends(ZLayer, _super);
function ZLayer(tilemap, zIndex) {
var _this = _super.call(this) || this;
_this._lastAnimationFrame = -1;
_this.tilemap = tilemap;
_this.z = zIndex;
return _this;
}
ZLayer.prototype.clear = function () {
var layers = this.children;
for (var i = 0; i < layers.length; i++)
layers[i].clear();
this._previousLayers = 0;
};
ZLayer.prototype.cacheIfDirty = function () {
var tilemap = this.tilemap;
var layers = this.children;
var modified = this._previousLayers != layers.length;
this._previousLayers = layers.length;
var buf = this.canvasBuffer;
var tempRender = this._tempRender;
if (!buf) {
buf = this.canvasBuffer = document.createElement('canvas');
tempRender = this._tempRender = new PIXI.CanvasRenderer(100, 100, { view: buf });
tempRender.context = tempRender.rootContext;
tempRender.plugins.tilemap.dontUseTransform = true;
}
if (buf.width != tilemap._layerWidth ||
buf.height != tilemap._layerHeight) {
buf.width = tilemap._layerWidth;
buf.height = tilemap._layerHeight;
modified = true;
}
var i;
if (!modified) {
for (i = 0; i < layers.length; i++) {
if (layers[i].isModified(this._lastAnimationFrame != tilemap.animationFrame)) {
modified = true;
break;
}
}
}
this._lastAnimationFrame = tilemap.animationFrame;
if (modified) {
if (tilemap._hackRenderer) {
tilemap._hackRenderer(tempRender);
}
tempRender.context.clearRect(0, 0, buf.width, buf.height);
for (i = 0; i < layers.length; i++) {
layers[i].clearModify();
layers[i].renderCanvas(tempRender);
}
}
this.layerTransform = this.worldTransform;
for (i = 0; i < layers.length; i++) {
this.layerTransform = layers[i].worldTransform;
break;
}
};
;
ZLayer.prototype.renderCanvas = function (renderer) {
this.cacheIfDirty();
var wt = this.layerTransform;
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution);
var tilemap = this.tilemap;
renderer.context.drawImage(this.canvasBuffer, 0, 0);
};
;
console.log('zzzzzzzzzzzzzzzzzzzzzzzzzzzZLayer: ', ZLayer);
return ZLayer;
}(PIXI.Container));
tilemap_1.ZLayer = ZLayer;
})(tilemap = PIXI.tilemap || (PIXI.tilemap = {}));
})(PIXI || (PIXI = {}));
ok am not shure at 100% but what do you think about
ShaderTilemap.prototype._paintAllTiles = function(startX, startY) {
is the good class to call function and add some children in the ZLayer ?
ok close #127 it solved. I hate this ShaderTilemap. 4 hours on and I think I have a solution. Why rmmv, do not do as UNITY and comment all codes.!!!!!!
pixiSSA._rmmvAlias.ShaderTilemap_paintAllTiles = ShaderTilemap.prototype._paintAllTiles;
ShaderTilemap.prototype._paintAllTiles = function(startX, startY) {
pixiSSA._rmmvAlias.ShaderTilemap_paintAllTiles.call(this,startX, startY);
// start add layer aniPictures
this.addPictureAniLayers(pixiSSA._animationControler._pictures);
}
//TODO: faire un scan de tous les layer possible, et ajouter de haut en bas. Le scan peut etre fait au debut dans le plugin parameter
ShaderTilemap.prototype.addPictureAniLayers = function(aniLayersContainers) {
console.log(this,'32áaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa32'); // wow work register Zindex
//create all layer, but need check if we assign special rmmv layer
for(layer in aniLayersContainers){
console.log('layer: ', layer);
if( aniLayersContainers[layer]._asignedRmmvLayer ){ // if assigned rmmv zLayer
var layerGameName = aniLayersContainers[layer]._asignedLayerGame;
if(layerGameName==='belowEvents'){ // couche sous Event dans lowerZLayer
console.log('belowEvents: +++++++++++++++++++++');
this.lowerZLayer.addChild(aniLayersContainers[layer]); // why i can no add all child to 0
}
}else{ // default Top Picture ZLayer TODO:
//this.addChild(aniLayersContainers[layer]);
}
}
};
how and when to add layers when map build? I try in several classes, but impossible. I want to avoid rewriting the pixi code, but I want to add child to this place. did you have triks ?
the addChildAt work one time , but after , they go in middle ???