Jump to content

Search the Community

Showing results for tags 'swap'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 5 results

  1. I'm trying to implement a system that allow the player to swap characters mid game. But I'm stuck. The idea is just to press a key and swap the current character with the next. That's it. I'm not sure how to approach it. First I tried to just use an If statement and just changing the value of the character, but that didn't work. The process was just create a new character like this.character = new Character({ game: this.game, x: this.world.centerX, y: this.world.centerY, asset: 'character1' }) this.game.add.existing(this.character) Then just every time a key was pressed (like A) call a function that would assign a new value to this.character. But it throw a null error so I give up. I like the swap mechanic but I don't know how do I make it work for different characters. Do I have to put all the characters (except the first one) off screen and change positions that way? on screen move off screen, off screen move on screen? Does it even work like that? is there already any implementation for this? Any idea or advice will be appreciated.
  2. Hi, I want to dynamically swap sprite texture ( i want it to be able to get texture from internet ), but i don't know why it sometimes not working, it become blank. i didn't use the requestAnimationFrame(animate) loop to minimize resources usage. and, can i resize sprite using drag? touch pinching ? Thank You the sample code : var renderer = PIXI.autoDetectRenderer(800, 600); document.body.appendChild(renderer.view); // create the root of the scene graph var stage = new PIXI.Container(); var bol = false; // create a texture from an image path var texture = PIXI.Texture.fromImage('_assets/flowerTop.png'); // create a second texture // var secondTexture = PIXI.Texture.fromImage('_assets/eggHead.png'); // create a new Sprite using the texture var dude = new PIXI.Sprite(texture); // center the sprites anchor point dude.anchor.set(0.5); // move the sprite to the center of the screen dude.position.x = renderer.width / 2; dude.position.y = renderer.height / 2; stage.addChild(dude); // make the sprite interactive dude.interactive = true; dude.on('click', function () { bol = !bol; if(texture){ texture.destroy(); } if(bol) { texture = PIXI.Texture.fromImage('_assets/flowerTop.png'); dude.texture = texture; } else { texture = PIXI.Texture.fromImage('_assets/eggHead .png'); dude.texture = texture; } renderer.render(stage); }); function animate() { requestAnimationFrame(animate); // just for fun, let's rotate mr rabbit a little dude.rotation += 0.1; // render the stage renderer.render(stage); } renderer.render(stage);
  3. Hello, I wanted to ask if there is a way to tween a state when we enter it or when we leave it. Basically if some animation like "fade-in/out" can be applied to states. After some search I found this: https://github.com/cristianbote/phaser-state-transition, but I'm not sure if it is compatible with the latest Phaser version. If anyone has used this let me know if it is worth it. Thanks.
  4. I am trying to swap 2 tiles (actually I just need to move a tile up/down/left/right, in place of an empty tile). I tried using tilemap.swap(tileA, tileB) but that only copies tileA over tileB, not the other way around too. The "swap tiles" example says it's supposed to really swap (copy A over B and B over A) but this doesn't happen there either. Is there any method that I am missing that can do this? And, since I am trying to move a tile over an empty place, is there a way to tween this move? Any help is greatly appreciated. Dan
  5. I'm trying to put together an effect in a game where every sprite and image gets changed to a 'corrupted' version. I've created two texture atlases (with the keys 'sprites' and 'sprites-hacked'); both have identical data, but one has its source image modified. Without delving deep into the code, does anyone know if it's possible to quickly swap out all of the textures to use a new atlas? I've got so far as to change all non-animating sprites and images by simply using loadTexture, however if any of them are animating, they revert to the old atlas on the next frame. Main.prototype.setHacked = function (group, val) { var h = (val === true) ? '-hacked' : ''; for (var i = 0, len = group.children.length; i < len; i++) { if (group.children[i] instanceof Phaser.Sprite || group.children[i] instanceof Phaser.Image || group.children[i] instanceof Phaser.TileSprite) { if (group.children[i].frameName) { group.children[i].loadTexture('sprites' + h, group.children[i].frameName || 0); } } else if (group.children[i] instanceof Phaser.Group) { this.setHacked(group.children[i], val); } } };Ideally, it'd be nice if there was something I could use at runtime to simply update the source image for the atlas lookups, however from testing I can only manage to do that before I create any of the sprites - it has no effect after they've been created. If there is no current way to do this, I reckon would be a really handy feature to have to enable 'palette swap' type effects like you see in a lot of old games.
×
×
  • Create New...