lars

Members
  • Content Count

    49
  • Joined

  • Last visited

Everything posted by lars

  1. Hello Everybody Trying to make a collision detection between two object. I have one object there is going to catch another object. Theres a new obejct to catcht every 10 seconds, and every thing goes fine when i catchs one object at time. But when theres multiple object on stage, something going wrong: Heres what im doing: Creating a "collector": this.spr_Con = new PIXI.Container(); this.scene.addChild(this.spr_Con); //Then creating the hitarea this.spr_hitArea = new PIXI.Graphics(); this.spr_hitArea.beginFill("0xffffff"); this.spr_hitArea.alpha= 0.5; this.spr_hitArea.drawRect(-20, 0, 40, 40); this.spr_Con.addChild(this.spr_hitArea); Then creating some objects to collide with: this.setNinja = setInterval(() => { this.spr_ninjaCon = new PIXI.Container(); this.scene.addChild(this.spr_ninjaCon); this.ninja_hitArea = new PIXI.Graphics(); this.ninja_hitArea.beginFill("0x000000"); this.ninja_hitArea.alpha= 0.5; this.ninja_hitArea.drawRect(-20, -20, 40, 40); this.spr_ninjaCon.addChild(this.ninja_hitArea); }, 10); //END interval So every 10 seconds i spawn a new object. Then I have a simple hittest class: export default class Hittest { constructor() { } checkme(a,b){ var ab = a.getBounds(); var bb = b.getBounds(); return ab.x + ab.width > bb.x && ab.x < bb.x + bb.width && ab.y + ab.height > bb.y && ab.y < bb.y + bb.height; } }; And check for intersection: this.app.ticker.add(() => { if ( this.collectNinjas.length > 0) { // is there any object if (this.ht.checkme(this.spr_hitArea, this.ninja_hitArea)) { console.log('intersection true'); this.scene.removeChild(this.spr_ninjaCon); } } }); //End app.ticker Every things goes fine as long as there is only one object "living" on stage, but as soon I have multiple object on stage it cant allways recognize the intersection. Is it my Hittest.js class that fails om multiple object? Hope someone can help me.
  2. lars

    Collision between one and multiple object

    Ok solved it, or my college did 🙂 this.collectNinjas.forEach(ninja =>{ if (this.ht.checkme(this.spr_hitArea, ninja )) { this.scene.removeChild(ninja); } } Thank you very much for the help Ivan. Super nice to have guys like you around 🙂
  3. lars

    Collision between one and multiple object

    Heres a working app. Its still in the Actors.js i doing my intersection. Thank you very much for having a look at it.
  4. lars

    Collision between one and multiple object

    Sorry. Theres only one comparison. So maybe thats the problem. But how do I compare with multiple object. I tried something like looping through my comparison this.setNinja = setInterval(() => { this.spr_ninjaCon = new PIXI.Container(); this.scene.addChild(this.spr_ninjaCon); this.ninja_hitArea = new PIXI.Graphics(); this.ninja_hitArea.beginFill("0x000000"); this.ninja_hitArea.alpha= 0.5; this.ninja_hitArea.drawRect(-20, -20, 40, 40); this.spr_ninjaCon.addChild(this.ninja_hitArea); this.collectNinjas.push(this.spr_ninjaCon); // pushing object into a array }, 10); //END interval These are drawn to stage in a interval And then I tried to compare intersection in a for loop like this: this.app.ticker.add(() => { if ( this.collectNinjas.length > 0) { // is there any object for(let ii = 0; ii < collectNinjas.length; ii++){ if (this.ht.checkme(this.spr_hitArea, collectNinjas[ii])) { console.log('intersection true'); this.scene.removeChild(this.spr_ninjaCon); } } } }); //End app.ticker But that did'nt do it. I will send you a clean working app 🙂 31/5000 31/5000
  5. lars

    Collision between one and multiple object

    Ok. Heres it is. And thank you very much for your time. Hope the code make sense 🙂 I have attached 2 files: The Hittest class and the Actor class. Where it all happens. Hopefully you will be able to read it in a minute 🙂 Hittest.js Actors.js
  6. lars

    disable multitouch

    Right now, when i want to "disable multitouch" I do the following: this.mouseCounter = 0: On a pointerDown event: this.mouseCounter++; if(this.mouseCounter < 2 ){ doSomeThing } On a pointerUp event: this.mouseCounter = 0; Simply q 🙂 Is there a better way to do this.
  7. Hello All I trying to make a object be dragged into a container and then be a child of this container like this: //places in a pointerup event let bl = otc.skeleton.findBone("left-hand-bone"); let point = oc.toGlobal({ 'x': bl.x, 'y': bl.y }); this.position.set(point.x - (oc.width - 5), point.y - (oc.height - 30)); // oCon.toLocal(this.position, this.parent, this.newPosition);//this i did not manage to get to work oc.addChild(this);//the container where drop the object(this) this.position.set(point.x - (oc.width - 30), point.y - (oc.height + 30)); And work fairly 🙂 But then when i want to drag the object out of the container again i gives me som problems: //placed in a pointerdown event if (globals.objectUsed) { // if the object is dragged to the new container in first place oCon.addChild(this); // send it back to its original container this.position.set(e.data.getLocalPosition(oCon).x, e.data.getLocalPosition(oCon).y); globals.objectUsed = false; isIntersected = false; } It´s kind of work. But the idea is that when the object is placed the first time and I want to drag it back to the original container its should happend when I startDrag(pointerdown), but i have to wait for the pointerup otherwise I still drag the object in its parent container (whichs is having a drag method. Could anyone guide be in the right direction it would be so nice ... hopefully me explaining its not to much rubbish 🙂 Regards Lars
  8. lars

    Drag into container and out again

    Hi Ivan My drag and is not included in my example, it´s work ok, only, some attemp to add a object from one container to another container, and atemp to get it back to the original container 🙂
  9. lars

    Check if a Spine animation is complete

    Thank´s a lot Enpu. Was actually looking in the Spine doc. But did´nt find it ... sorry :-)
  10. Hello Anyone knows how to check if a Spine animation is complete. Tried: player.onComplete();
  11. lars

    Spine and events

    That did it. thank´s a lot :-)
  12. lars

    Spine and events

    Hello Im trying to make my spine object interactive: var player = new game.Spine('mySpine.json'); //player.hitArea = new game.Rectangle(200, 500); player.position.set(300, 800); player.interactive = true; player.play('idle', true); //player.speed = 0.01 player.addTo(this.stage); player.click = function() { console.log('check clicked'); }; That did not work. I tried to put it in a container. That did not help either. It works OK an a sprite object.
  13. lars

    Spine and events

    Yes im using Pixi plugin and my spine works fine, but is not interactive. Where do I disable webGL. Tried to set it to false in the config.
  14. lars

    Spine and events

    Ok. I tried that to, and I cannot visual see the debug draw in the Panda2 editor when activate #. If I work outside Panda2 editor (Brackets) would i still be possible for me to debug the hit area in a browser like: ?debugDraw=true Heres what i tried (I startet with a class, but for now, to test is down to basic :-) : var container = new game.Container(); container.position.set(300, 800); container.interactive = true; container.hitArea = new game.Rectangle(237.15, 218.37); container.hitArea.x = -200; container.hitArea.y = 218; container.addTo(this.stage); var player = new game.Spine('kristian-ronnie.json'); //player.hitArea = new game.Rectangle(200, 500); //player.position.set(300, 800); player.play('idle', true); player.addTo(container); container.click = function() { console.log('check clicked'); }; }
  15. lars

    Spine and mesh

    Works perfectly :-) Thanks
  16. lars

    Spine and mesh

    Hello First of all. I m so glad to see Panda on the road again :-) I have just bought the full version and playing around with Spritesheets developed in Spine 3.6.52 professional. It seems like mesh is not supported in panda 2 version 1.5.0. When I export from spine as a spritesheet with mesh animations it won´t show the spritesheet, If i remove the Mesh animation it shows the animation fine: game.module( 'game.main' ) .require( 'plugin.spine' ) .body(function() { //game.addAsset('panda.png'); game.addAsset('sheep.atlas'); game.addAsset('sheep.json'); game.createScene('Main', { init: function() { var player = new game.Player(); player.sprite.addTo(this.stage); } }); game.createClass('Player', { init: function() { //this.sprite = new game.Sprite('panda.png'); this.sprite = new game.Spine('sheep.json'); this.sprite.position.x = 200; this.sprite.position.y = 800; this.sprite.play('idle', true); } }); });
  17. lars

    Spine and mesh

    So cool.
  18. lars

    Spine and mesh

    Super fantastic ... I really like what you have done with Panda...
  19. lars

    Loader in Pandajs 2

    Hello everyone I´m having some issues with the Loader in Pandajs 2 When i do the following: this.loader.onStart = this.setGame.bind(this); this.loader.onComplete = this.loadingGame.bind(this); this.loader.start(); Everything is just fine: But when I try to make a onProgress the onProgress does not response: this.loader.onStart = this.setGame.bind(this); this.loader.onProgress = this.processGame.bind(this); this.loader.onComplete = this.loadingGame.bind(this); this.loader.start(); I can see it, and trace it in the Loader.js class : onProgress: function() { //console.log(this.percent); //if (this.barFg) this.barFg.scale.x = this.percent / 100; } Her is a simple implementation I done: game.module( 'game.start' ) .require( 'game.assets' ) .body(function() { game.createScene('Start', { backgroundColor: '#5ca282', init: function() { this.loader = new game.Loader(); this.loader.onStart = this.setGame.bind(this); this.loader.onProgress = this.processGame.bind(this); this.loader.onComplete = this.loadingGame.bind(this); this.loader.start(); }, //END init setGame: function() { console.log('started'); }, processGame: function() { console.log('percent'); }, loadingGame: function() { document.getElementById('loading').style.display = "none"; this.startContainer = new game.Container().addTo(this.stage); if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { this.mytastatur = new game.Sprite('tastatur').addTo(this.startContainer); } else { this.mytastatur = new game.Sprite('uden-tastatur').addTo(this.startContainer); } this.mytastatur.position.x = game.system.width / 2 - this.mytastatur.width / 2; this.mytastatur.position.y = 0; this.mytastatur.interactive = true; this.mytastatur.click = this.mytastatur.tap = this.changeScene.bind(this, "Main"); }, changeScene: function(go) { game.system.setScene(go); var playbg = game.audio.playMusic('bb', true); game.audio.setVolume(playbg, 0.2); }, }) //END Start }); Anybody knows what wrong with onProgress on the Loader. /Lars
  20. lars

    Loader in Pandajs 2

    Ehh .... ok. No support of MP3 :-)
  21. lars

    Loader in Pandajs 2

    Only one thing: If I try to preload mp3 like: game.addMedia('sound/soundwaterdrop.*', 'water'); Errror: Uncaught Unsupported file format * or game.addMedia('sound/soundwaterdrop.mp3', 'water'); Error: Unsupported file format mp3 This happens in the updated 2.0 version: https://github.com/ekelokorpi/panda-engine/tree/develop/src Have been trying to look around in the Loader.js file ... but ... :-)
  22. lars

    Loader in Pandajs 2

    Hello Enpu So f...... nice to have you back :-) . It´s working now. Thanks a lot ... Heres how I did (just a dummy, with some stolen parts), and put a reference in the config.js file as you said :-) : game.config = { system: { width: 1024, height: 768, center: true, scale: true, loader: 'MyLoader' } }; And the dummy loader: game.module( 'game.main' ) .require( 'game.assets' ) .body(function() { this.bar; game.createClass('MyLoader', 'Loader', { onStart: function() { this.bar = new game.Graphics(); this.bar.beginFill('#ccc'); this.bar.drawRect(0, 0, 260, 40); this.bar.x = game.system.width / 2 - (260 / 2); this.bar.y = game.system.height / 2 - (40 / 2); this.bar.scale.x = this.percent / 100; this.bar.addTo(this.stage); }, onProgress: function() { console.log(this.percent); //console.log(this.sprite.x); this.bar.scale.x = this.percent / 100; }, onComplete: function() { game.system.setScene('Main'); } }); game.createScene('Main', { backgroundColor: '#666', init: function() { console.log('opo'); } }); });
  23. lars

    Loader in Pandajs 2

    I have tried with a panda 2 update version from: https://github.com/ekelokorpi/panda-engine/tree/develop/src And tried the following: game.module( 'game.main' ) .body(function() { game.addMedia('baggrund_level1.png','bb'); game.createScene('Main', { backgroundColor: '#666', init: function() { console.log('im started'); this.loader = new game.Loader(); this.loader.onStart = this.setGame.bind(this); this.loader.onProgress = this.setPercentGame.bind(this); this.loader.onComplete = this.loadingGame.bind(this); this.loader.start(); }, setGame: function() { console.log('Started'); }, setPercentGame: function() { console.log('percent'); }, loadingGame: function(){ var sprite = new game.Sprite('bb'); sprite.addTo(this.stage); } }); }); With the same result. No response from the onProgress listener.
  24. lars

    Loader in Pandajs 2

    And heres the file that starting the game with the loader: assets.js
  25. lars

    Loader in Pandajs 2

    Hello Enpu Yes I have a assets.js which holding the following: game.module( 'game.assets' ) .body(function() { game.addAsset('newgra/tastatur.jpg', 'tastatur'); game.addAsset('newgra/uden-tastatur.jpg', 'uden-tastatur'); game.addAsset('newgra/aeggeskilt.png', 'level1'); game.addAsset('newgra/aeggeskilt.png', 'level2'); game.addAsset('newgra/aeggeskilt.png', 'level3'); game.addAsset('newgra/forgrund.png', 'bord'); game.addAsset('newgra/baggrund.png', 'stribes'); game.addAsset('newgra/bg-himmel.jpg', 'heaven'); game.addAsset('newgra/baggrund_level1.png', 'baglevel1'); game.addAsset('newgra/baggrund_level2.png', 'baglevel2'); game.addAsset('newgra/baggrund_level3.png', 'baglevel3'); game.addAsset('newgra/rabbit.json'); game.addAsset('newgra/kylling.json'); game.addAsset('newgra/fox.json'); game.addAsset('newgra/smallchicken.json'); game.addAsset('newgra/chickenweapon.json'); game.addAsset('newgra/eggglow.json'); game.addAsset('newgra/eggglow_blue.json'); game.addAsset('newgra/eggglow_purple.json'); game.addAsset('newgra/plane.json'); game.addAsset('newgra/cheep.json'); game.addAsset('newgra/chickenbaloonfly.json'); game.addAsset('newgra/gennemfoert-lvl1.jpg', 'level1done'); game.addAsset('newgra/gennemfoert-lvl2.jpg', 'level2done'); game.addAsset('newgra/gennemfoert-lvl3.jpg', 'level3done'); game.addAsset('newgra/shitbullet.png', 'bullets'); game.addAsset('newgra/karamel.png', 'bigagurk'); game.addAsset('newgra/karamel_small.png', 'peachs'); game.addAsset('newgra/karamel2_small.png', 'peachs2'); game.addAsset('newgra/karamel3_small.png', 'peachs3'); game.addAsset('newgra/karamel4_small.png', 'peachs4'); game.addAsset('newgra/sun.json'); game.addAsset('newgra/eggs/aeg1-1.png', 'sam1'); game.addAsset('newgra/eggs/aeg1-2.png', 'sam2'); game.addAsset('newgra/eggs/aeg1-3.png', 'sam3'); game.addAsset('newgra/eggs/aeg-2-1.png', 'sam4'); game.addAsset('newgra/eggs/aeg-2-2.png', 'sam5'); game.addAsset('newgra/eggs/aeg-2-3.png', 'sam6'); game.addAsset('newgra/eggs/aeg3-1.png', 'sam7'); game.addAsset('newgra/eggs/aeg3-2.png', 'sam8'); game.addAsset('newgra/eggs/aeg3-3.png', 'sam9'); game.addAsset('newgra/eggs/aeg1-1-mini.png', 'sam1-mini'); game.addAsset('newgra/eggs/aeg1-2-mini.png', 'sam2-mini'); game.addAsset('newgra/eggs/aeg1-3-mini.png', 'sam3-mini'); game.addAsset('newgra/eggs/aeg-2-1-mini.png', 'sam4-mini'); game.addAsset('newgra/eggs/aeg-2-2-mini.png', 'sam5-mini'); game.addAsset('newgra/eggs/aeg-2-3-mini.png', 'sam6-mini'); game.addAsset('newgra/eggs/aeg3-1-mini.png', 'sam7-mini'); game.addAsset('newgra/eggs/aeg3-2-mini.png', 'sam8-mini'); game.addAsset('newgra/eggs/aeg3-3-mini.png', 'sam9-mini'); game.addAsset('newgra/button-left.png', 'jump'); game.addAsset('newgra/button-right.png', 'shooting'); game.addAsset('particle.png', 'particle'); game.addAsset('testfont.fnt'); game.addAudio('sound/waterdrop.*', 'water'); game.addAudio('sound/fruit.*', 'fruit'); game.addAudio('sound/newsound/baggrund_paaskespil.*', 'bb'); game.addAudio('sound/newsound/baggrund_paaskespil2.*', 'bb2'); game.addAudio('sound/newsound/baggrund_paaskespil3.*', 'bb3'); game.addAudio('sound/newsound/Fail_0.*', 'fail0'); game.addAudio('sound/newsound/Fail_1.*', 'fail1'); game.addAudio('sound/newsound/Fail_2.*', 'fail2'); game.addAudio('sound/newsound/done_level1.*', 'goal1'); game.addAudio('sound/newsound/done_level2.*', 'goal2'); game.addAudio('sound/newsound/done_level3.*', 'goal3'); game.addAudio('sound/newsound/first_course.*', 'hint4'); game.addAudio('sound/newsound/airplane.*', 'airplane'); game.addAudio('sound/newsound/sheep.*', 'sheepsound'); game.addAudio('sound/newsound/biplane.*', 'biplane'); game.addAudio('sound/newsound/collectegg.*', 'collectegg'); game.addAudio('sound/newsound/shoot.*', 'shoot'); game.addAudio('sound/newsound/shoot1.*', 'shoot1'); game.addAudio('sound/newsound/shoot2.*', 'shoot2'); game.addAudio('sound/newsound/fanfare.*', 'fanfare'); });