DeusX

Members
  • Content Count

    14
  • Joined

  • Last visited

  1. DeusX

    pixels() returns only 0

    I made a stationary and fast example right now and it seems to work, thanks. I will include that functionality in my game in the next days and will supply a solution to the problem here.
  2. DeusX

    Apply Filter only to small area

    Awesome, I'm gonna try that as well as soon as I have time.
  3. DeusX

    pixels() returns only 0

    I can't test it right now but from what I understand this should work? Where 100 and 50 are the size of the sprite. And in my handler I keep my code(with addition of accounting for the things you listed) and work with the this.pixels array? let canvas = this.app.renderer.plugins.extract.canvas(); let context = canvas.getContext("2d"); context.drawImage(this.sprite.texture.baseTexture.source, 0, 0, 100, 50 ); this.pixels = (context.getImageData(0, 0, 100, 50).data);
  4. DeusX

    Apply Filter only to small area

    I tried your solution with the grey frame around the texture and it works actually great, thanks.
  5. DeusX

    pixels() returns only 0

    So, I checked it again and the problem was neither CORS nor the webgl context. First of all, I didn't really check the entire array because it was simply too large. I used the following to get the pixel values where I clicked. But this does only work if I don't resize the image. If I use e.g. this.sprite.width = 100, this.sprite.height = 50 it only logs zero. Is there a possibilty to adjust the size and keep the pixel values correct? this.sprite.on("pointerdown", () => { let px = Math.floor(this.app.renderer.plugins.interaction.mouse.global.x - this.sprite.x); let py = Math.floor(this.app.renderer.plugins.interaction.mouse.global.y - this.sprite.y); let index = (px+py * this.sprite.width) * 4; console.log(this.app.renderer.extract.pixels(this.sprite)[index]); )};
  6. DeusX

    Apply Filter only to small area

    So, your workaround is to just put a grey frame around the texture with gimp or something? Haven't thought of that yet lol, I will try that solution tomorrow and provide Feedback. Your general solution would be nice I think as this should be a rather common problem I suppose. I will take a look at your fiddle after trying the border solution. Thanks
  7. DeusX

    Apply Filter only to small area

    Hello, I'm currently working on a little game with and Island and some (right now static) water, I was looking online for water-effects and found this, simple Article https://markhawkinsdesigns.com/blog/web-design/working-with-pixijs-v4-and-the-displacementfilter/ I really like that effect but how do I restrict the area so that some of the image (especially the borders of the image, they look weird) stays uneffected, right now it looks a bit like wet paper instead of water. I tried using masking but that doesn't really help because now we have the same Image in the background but the edges of the foreground are still moving. Restricting filterArea and changing the padding doesn't really work also. My Goal right now is that the edges of the images stay static respectively uneffected by the filter. Thanks.
  8. DeusX

    pixels() returns only 0

    I'm working on the first point, but I don't think this is the case here. btw, renderer.gl.isContextLost() always returns false so I think there are no other contexts are created.
  9. DeusX

    pixels() returns only 0

    So, I just set up a plain canvas and tried it with the ctx.getImageData(...) function, this returns the same Array with just all zeroes. Any Ideas why this is happening?
  10. DeusX

    pixels() returns only 0

    I'm using the electron framework to create a desktop application
  11. DeusX

    pixels() returns only 0

    Hello, I'm currently working on some small project with pixi but with more complex shapes. Now I wanted to look at the image data of my sprites but the pixel values are all 0. I searched on google and a few suggestions were that the renderer hasn't rendered anything yet or that the sprites weren't loaded, but this is not the case because if I take another sprite (the cat from https://github.com/kittykatattack/learningPixi) my program suddenly works (I get an array with more than just all 0). Does this have something to do with my images? They are just .png files with a transparent background. let Application = PIXI.Application; let loader = PIXI.loader; this.app = new Application({width: 556, height: 556}); this.cat = null; document.body.appendChild(this.app.view); loader .add("sprites/cat.png") .load((loader, resources) => { this.cat = new PIXI.Sprite(PIXI.loader.resources["sprites/cat.png"].texture); this.cat.x = 100; this.cat.y = 100; this.cat.anchor.x = 0.5; this.cat.anchor.y = 0.5; this.app.stage.addChild(this.cat); console.log(this.app.renderer.extract.pixels(this.cat)); this.app.ticker.add(delta => this.mainLoop(delta)); }); //this works fine, but if I take something else than the cat.png it doesn't work anymore Thanks
  12. Hello, I know this is my second Thread today but I found out about this forum today and I'm curious about the Problems I had while learning Phaser the past week, so sorry for that^^ My first game was a simple point&click game, where you could click an (moving) image & that image would appear somewhere new at random. Now the problem is that everytime I restart the scene (using this.scene.restart()) the object would start to stutter in the "new" Scene. The object always started in a random location and moved with moveTo(endX, endY, 100) to the other location. Is this because of the moveTo function? Should I use another approach for moving the object? I can supply a code sample later on. //startLocations and endLocations are Arrays containing random positions where the object should start and where it should go to create() { this.player = this.physics.add.sprite(this.startLocationsX.pop(), this.startLocationsY.pop(), "coin"); this.player.setCollideWorldBounds(true); this.player.setBounce(1); this.angle = this.physics.moveTo(this.player, this.endLocationsX.pop(), this.endLocationsX.pop(), 200); } //my config const config = { type: Phaser.AUTO, width: window.innerWidth, height: window.innerHeight, fps: 60, scene : [Game], physics: { default: 'arcade', arcade: { gravity: { y: 0 }, } }, } //and a reset function for when to object was clicked reset() { this.scene.restart(); } Thanks
  13. DeusX

    Clicks on Object and Background

    thanks to both of you, that solved my problem
  14. Hello, I'm new to Phaser and currently playing with/learning phaser 3, I wrote a simple clicker game, where you just click on an object as long as you want and you will get Points for it. Pretty easy so far, but now I want clicks on the background to do something else. this.cookie = this.physics.add.sprite(400, 400, "cookie"); this.cookie.setInteractive(); this.handleObjectInput(this); handleObjectInput(context) { this.input.on('gameobjectup',(pointer, gameObject) => { //do stuff with the clicks on the cookie }); } In my update function I call a function that checks wether the background has been clicked handleInput() { if(this.input.activePointer.justDown) { //do stuff unrelated to the cookie } } But now my Problem is that every time I click on the cookie, the handle Input function is called as well, which it shouldn't. I want the cookie sprite and the background to be two different "entitys". I tried assigning an eventhandler to the background as well but then a click on the background gets also registered on the cookie. Thanks.