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

app.js changed, bugged layers

Dim Dim пре 6 година
родитељ
комит
cb9f94e248
2 измењених фајлова са 21 додато и 5 уклоњено
  1. 2 1
      src/Game/app.js
  2. 19 4
      src/Game/views/demo/CardCollectionDemo.js

+ 2 - 1
src/Game/app.js

@@ -1,6 +1,7 @@
 import './app.css';
 import * as PIXI from 'pixi.js';
 import * as tweenManager from 'pixi-tween';
+import 'pixi-layers';
 
 import Router from './Router.js';
 
@@ -25,7 +26,7 @@ class App {
 		window.onresize = this.resize;
 		this.app.view.style.display = 'none';
 		document.body.appendChild(this.app.view);
-
+		this.app.stage = new PIXI.display.Stage();
 		this.viewStage = new PIXI.Container();
 		// var graphics = new PIXI.Graphics();
 		// graphics.beginFill(0xFFFF00,0.2);

+ 19 - 4
src/Game/views/demo/CardCollectionDemo.js

@@ -5,15 +5,30 @@ import CardCollection from '../base/CardCollection';
 import CollectionDeck from '../base/CollectionDeck';
 
 class CardCollectionDemo extends PIXI.Container{
-	constructor(){
+	constructor(props){
 		super();
 
-		var layer = new PIXI.display.Layer();
+		let {
+			GameLayer
+		} = props;
 
+		var layer = new PIXI.display.Layer();
+		var layer2 = new PIXI.display.Layer();
 		let cardCollection = new CardCollection({});
-		this.addChild(cardCollection);
+		//cardCollection.parentLayer = layer;
+		layer.addChild(cardCollection);
+		cardCollection.zIndex = 1;
+		// this.addChild(cardCollection);
 		let collectionDeck = new CollectionDeck({'x': 600, 'y':0 });
-		this.addChild(collectionDeck);
+		//collectionDeck.parentLayer = layer;
+		layer2.addChild(collectionDeck);
+		collectionDeck.zIndex = 2;
+		// this.addChild(collectionDeck);
+		GameLayer.app.stage.addChild(layer2);
+		GameLayer.app.stage.addChild(layer);
+		
+		this.addChild(layer);
+		this.addChild(layer2);
 		// this.setChildIndex(collectionDeck, 0);
 		// this.setChildIndex(cardCollection,1);
 	}