LinkTree

Members
  • Content Count

    87
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by LinkTree

  1. LinkTree

    Panda 2 development

    @ThanosS You didn't try to modify/extend the engine's physics module? The last update was 2 months ago so it's not that long but yea it definitely seems to have slowed down. Phaser has a lot more developers working on it so that's why there are more frequent updates. What I loved originally about panda was it's writing style, modularity and classes similar to Impact.js and that it offered a canvas+webGL renderer on top. I preferred using it even though I own an Impact.js license but with the ES6 modules and classes soon to be included I guess you could probably use Phaser in a similar way without needing to build it with webpack/common.js. In some ways having less features is also good in some cases because you won't be using all of Phaser's features in every single game so you are adding a lot of unrequired code.
  2. What engine version? I tested in v2 and game.scene.addTimer(1000, function() { console.log("timer"); works fine. The reason this.addTimer didn't work in your example is because this refers to the Class class you are extending and it doesn't have an addTimer method. if you wanted your class to have an addTimer method you could extend the Container class instead, or use the Timer class in your own class in a similar way to how the Container/Scene classes are using it. http://ekelokorpi.github.io/panda.js-site/engine/docs/files/src_engine_scene.js.html#l131
  3. LinkTree

    Panda 2 development

    I see this was over a month ago. Did you find the solution to your issue? @enpu Hey Eemeli, We haven't heard from you in a while. I wanted to make sure everything is alright with you. Are there any news regarding the development of Panda 2?
  4. I solved it! had to use the _renderCanvas (or _render either will work) function of the Container class.
  5. Hi ThanosS, Thank you for your suggestion. I don't have a problem with creating a static blurred background. It's quite simple and there are multiple ways of doing that. What I am trying to create is a dynamic background that changes according to what's behind it in real-time. For that I think I have to use the update function and maybe modify some rendering function but I am not sure and I can't wrap my head around it. Edit: I think I have to edit or extend the engine's renderer to detect my menu class and get the canvas image at that point before it renders the menu itself.
  6. I've been trying to implement a menu with a dynamic blurred background behind it for a few days now and I just can't get it to work the way I want it. what I did was to set my menu's update function to copy a rectangle in the size and position of my menu from the game canvas to an off-screen canvas and then blur the off-screen canvas and set a sprite with a the returned texture then draw the menu itself on top of that blurred sprite. The problem is that it copies and blurs the menu itself as well. The only good solution I could think of was to create that menu in html and style it with css and feed it with data and images from the game using toDataURL(). But I really want to make it 100% canvas. the second solution I thought about was to run the game twice and not add the menu container in the second game but it sounds extremely wrong and will hit the game performance. Is there a way to render the off-screen canvas while excluding specific objects? or getting the canvas image before the menu is drawn to it? I couldn't figure it out and I tried many things. I don't want to edit the game engine itself but I might have to. Thank you.
  7. I agree, I was asking myself the same question. I believe it's not a case of it being replaced but just not implemented yet.
  8. LinkTree

    Panda 2 development

    I did a quick and dirty test and it seems like anchors work fine during loading. I was able to rotate the progress bar by it's center point and also when I added an image to the scene I was able to rotate it by it's center as well. what didn't work for me is when I loaded the image the loader got stuck but that could be due to me not loading the image properly I haven't tested it heavily just wanted to do something quick. http://ekelokorpi.github.io/panda.js-site/engine/playground/#container_basic game.addAsset('panda.png');game.Loader.inject({ onStart: function() { if (this._dynamic) return; var sprite = new game.Sprite('panda.png'); sprite.position.set(100,100); sprite.anchorCenter(); sprite.rotation = Math.PI/2; sprite.addTo(this.stage); var barWidth = game.Loader.barWidth; var barHeight = game.Loader.barHeight; var barBg = new game.Graphics(); barBg.beginFill(game.Loader.barBgColor); barBg.drawRect(0, 0, barWidth, barHeight); barBg.position.set(game.system.width / 2 - barWidth / 2, game.system.height / 2 - barHeight / 2); barBg.addTo(this.stage); this.barFg = new game.Graphics(); this.barFg.beginFill("#FF0000"); this.barFg.drawRect(0, 0, barWidth, barHeight); this.barFg.position.set(game.system.width / 2, game.system.height / 2); // this.barFg.anchorCenter(); this.barFg.anchor.set(100,10); this.barFg.rotation = Math.PI/2; this.barFg.addTo(this.stage); this.onProgress(); }})game.createScene('Main', { init: function() { var container = new game.Container(); container.position.set(100, 100); container.addTo(this.stage); var sprite = new game.Sprite('panda.png'); sprite.addTo(container); }});
  9. LinkTree

    Panda 2 development

    I delved into the source code to find a solution for this and I came out with this fix: in loader.js change the parseJSON function to this: parseJSON: function(filePath, callback, request) { if (!request.responseText || request.status === 404) callback('Error loading JSON ' + filePath); var json = JSON.parse(request.responseText); game.json[filePath] = json; if (json.frames) { // Sprite sheet var image = game._getFilePath(json.meta.image); this.loadImage(image, this.parseSpriteSheet.bind(this, json, callback)); return; }else{ callback(); } return json; }
  10. LinkTree

    Panda 2 development

    I just tested it myself, I am getting the same result as you without any errors in both firefox and chrome. That's definitely an issue. Hopefully Enpu will notice this soon. from my test it seems like the init function of the main scene doesn't get executed. There's probably some method that holds up on executing it until all the files are loaded but the JSON file loader maybe never reports back that the file loaded successfully and it get's stuck. I don't know... it's just an assumption.
  11. LinkTree

    Panda 2 development

    Hmmmm... Interesting. did you find a solution for this yet? I don't have an iphone/ipad currently so I can't test this myself unfortunately. :/
  12. LinkTree

    Panda 2 development

    I think it's because you are trying to get the JSON data before it's fully loaded. Try to add an assets.js module and require it in the main module. Something like this: assets.js game.module( 'game.assets').body(function() { game.addAsset('parser.json', 'parserLoads');});main.js game.module( 'game.main').require( 'assets.js').body(function() {game.createScene('Main', {init: function() {var sampleScript = game.getJSON('parserLoads');console.log(sampleScript);}});});
  13. Fantastic stuff man! I agree with Steve's comment, I think you are selling yourself short.
  14. You're welcome, I am glad you could find use for this.
  15. LinkTree

    Panda 2 development

    What is it that you are trying to do? My first idea would be to set a boolean variable within the scope to true whenever an object is being touched and to false whenever it's not. and on the object's mousedown function check whether this variable is set to false before you execute the handler's code.
  16. I ported the Three.js plugin from the panda 1.3 plugins repository to work with panda 2.0. you can find it here: https://github.com/LinkTree3/Panda.js-plugins Usage example taken from the 1.3 plugins repository: game.module( 'game.main').require( 'plugins.three').body(function() {game.createClass('Box', { init: function(width, height, depth) { this.geometry = new game.THREE.BoxGeometry(width, height, depth); this.material = new game.THREE.MeshBasicMaterial({ color: Math.round(Math.random() * 16777215), }); this.mesh = new game.THREE.Mesh(this.geometry, this.material); game.scene.scene.add(this.mesh); }, update: function() { this.mesh.rotation.x += 1 * game.system.delta; this.mesh.rotation.y += 2 * game.system.delta; }});game.createScene('Main', { init: function() { this.scene = new game.THREE.Scene(); this.camera = new game.THREE.PerspectiveCamera(75, game.system.width / game.system.height, 1, 10000); this.camera.position.z = game.system.height; this.camera.position.x = game.system.width / 2; this.camera.position.y = game.system.height / 2; for (var i = 0; i < 10; i++) { var box = new game.Box(200, 200, 200); box.mesh.position.x = Math.random() * game.system.width; box.mesh.position.y = Math.random() * game.system.height; box.mesh.position.z = -Math.random() * 1000; this.addObject(box); } }});});
  17. LinkTree

    Panda 2 development

    I apologize for my previous wrong suggestion. I dug deeper and researched how the tweening is done now and how it used to be done in 1.3. This took longer than I thought it would because from your previous message I was under the impression stopTweensForObject used to take any object(hero) and stop all the tweens on it but after I read the code and experimented with the 1.3 version I realized this was not the case and you had to specify the attribute you want to cancel tweening for. So instead of stopTweensForObject(hero) it would be stopTweensForObject(hero.scale). here's the code that worked for me in v2.0 game.stopTweensForObject = function(object) { for (var i = game.scene.tweens.length - 1; i >= 0; i--) { if (game.scene.tweens[i].object === object) game.scene.tweens[i].stop(); }}var sprite = new game.Sprite('eye.png');sprite.anchorCenter();sprite.position.set(100, 100);sprite.addTo(this.stage);var tween = new game.Tween(sprite.scale);tween.to({x:0.5,y:0.5},2000).repeat().yoyo().start();game.stopTweensForObject(sprite.scale);To restart a tween I assume you just stop() it and start() it right after. You can even chain them together.
  18. LinkTree

    Panda 2 development

    I think it was removed in 2.0. you can add it yourself though. Here's the function from 1.3: stopTweensForObject: function(object) {for (var i = this.tweens.length - 1; i >= 0; i--) {if (this.tweens[i].object === object) this.tweens[i].stop();}}you can do something like game.stopTweensForObject = function(object) {for (var i = object.tweens.length - 1; i >= 0; i--) {if (object.tweens[i].object === object) object.tweens[i].stop();}}Pretty sure this should work.
  19. LinkTree

    spriteTinter

    Alright. And you're welcome!
  20. LinkTree

    spriteTinter

    Hmmm... I just updated to the latest panda version and everything works. I am not sure what could be causing this... can you please create a working example representing the issue?
  21. LinkTree

    spriteTinter

    Are you using the 2.0 version? I am not sure but I think the first error is due to game.FastContainer not existing and it indeed doesn't exist in the 1.3 version.
  22. LinkTree

    spriteTinter

    this worked for me: game.createClass('Anim','Animation',{ textures: ['eye.png', 'eye2.png'], interactive: true, buttonMode: true, init: function(x, y, container){ this.anchor.set(this.width/2, 0); this.position.set(x, y); this.addTo(container); this.off = true; }});var anim = new game.Anim(100,100,game.scene.stage);anim.tint = "#ff0000";anim.play();Maybe it is something else that causes it. are you getting any errors in your console?
  23. LinkTree

    spriteTinter

    Hmmm... I just tried it with a game.Animation and it worked fine. did you override the default rendering of game.Animation with game.LightSwitch? this worked for me: var anim = new game.Animation(['eye.png','eye2.png']);anim.play();anim.tint = "#ff0000";anim.addTo(game.scene.stage);Edit: I haven't seen your game.LightSwitch code but my assumption is that the problem might be in it's init function.
  24. LinkTree

    spriteTinter

    is game.LightSwitch a class extended from game.Sprite?