Jump to content

Search the Community

Showing results for tags 'sprite group'.

  • 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 4 results

  1. Hey there! I was wondering how you stop all animations in a sprite group when clicking one of them. I can't seem to get it to work. Heres my code that deals with it: function create(){ cardPack = game.add.group(); cardPack.create(game.world.centerX - 250, game.world.centerY, 'card'); cardPack.create(game.world.centerX - 75, game.world.centerY, 'card'); cardPack.create(game.world.centerX + 100, game.world.centerY, 'card'); cardPack.callAll('animations.add', 'animations', 'flip', [0,1,2,3], 12, true); cardPack.callAll('play', null, 'flip'); cardPack.setAll('inputEnabled', true); cardPack.setAll('input.useHandCursor', true); cardPack.setAll('events.onInputDown.addOnce', stopAnimation, this); cardPack.setAll('input.priorityID', 1); } function stopAnimation(){ cardPack.callAll('animations.stop', 'animations', null, true); } Is the error in the callAll for the animation stop or in the setAlll for event onInputDown? I've tried manipulating both and looking for examples for this but I'm coming up empty handed or just not searching correctly.
  2. var game = new Phaser.Game(1024,768,Phaser.AUTO, 'space game', {preload: preload, create: create, update: update}); var ships; var ship; function preload(){ game.load.image('spaceship', 'assets/spaceship_sprite.png'); game.load.image('menu', 'assets/menu.png'); } function create(){ ship = game.add.sprite(500,680, 'spaceship'); game.physics.arcade.enable(ship); ship.scale.setTo(0.5,0.5); //ship2 = myship(game, 'spaceship', 600, 200); ships = game.add.group(); for (var i = 0; i < 0; i++){ //var sx = 100; ships.create(600, 200, 'spaceship'); //myship(game, 'spaceship', 500+sx, 200); //sx += 100; //game.add.sprite(500, 200, 'spaceship'); } cursors = game.input.keyboard.createCursorKeys(); pauseKey = game.input.keyboard.addKey(Phaser.Keyboard.ONE); pauseKey.onDown.add(addMenu, this); game.input.keyboard.removeKeyCapture(Phaser.Keyboard.ONE); } function update(){ if(cursors.left.isDown){ ship.body.x += -7; } if(cursors.right.isDown){ ship.body.x += 7; } } function addMenu(){ game.add.sprite(100,100,'menu'); } 1. I want to add a few sprites of a ship into the 'ships' group. But for loop doesn't work. I'm folowing this example: https://phaser.io/examples/v2/groups/add-a-sprite-to-group#gv even If I try to add object from external script. I've tried to create a few ships of 'myship' without the 'for loop' and it works fine. 2. If I uncomment this line: //ship2 = myship(game, 'spaceship', 600, 200), my 'ship' doesn't move (key input doesn't work). What am I doing wrong? Sorry for my poor english.
  3. Howdy all, I've looked everywhere but I can't seem to find an answer. I'm making an infinite scroller. The platforms are automatically generated and they are made up of a pool of floor sprites nested into a pool of platforms (groups of floor sprites). For example: // Creating platforms in Game.js createPlatform: function(){ var nextPlatformData = this.generateRandomPlatform(); if (nextPlatformData) { this.currentPlatform = this.platformPool.getFirstDead(); if (!this.currentPlatform) { this.currentPlatform = new SupRun.Platform( this.game, this.floorPool, nextPlatformData.numTiles,this.game.world.width + nextPlatformData.separation, nextPlatformData.y, -this.levelSpeed, this.coinsPool, this.enemiesPool, this.enemySprite, this.player, false); } else { this.currentPlatform.prepare( nextPlatformData.numTiles, this.game.world.width + nextPlatformData.separation, nextPlatformData.y, -this.levelSpeed, this.coinsPool, this.enemiesPool, this.enemySprite, this.player, false); } this.platformPool.add(this.currentPlatform); this.currIndex++; } } //Creating groups of floor sprites in Platform.js prefab SupRun.Platform.prototype.prepare = function(numTiles, x, y, speed, player) { //console.log(speed); this.alive = true; var i = 0; while(i < numTiles){ var floorTile = this.floorPool.getFirstExists(false); if (!floorTile){ floorTile = new Phaser.Sprite(this.game, x + i * this.tileSize, y, 'floor'); } else { floorTile.reset(x + i * this.tileSize, y); } this.add(floorTile); i++; } //set physics properties this.setAll('body.immovable', true); this.setAll('body.allowGravity', false); this.setAll('body.velocity.x', speed); this.addCoins(speed); this.addEnemies(speed, this.player); }; The player collides with the top of the of the platforms just fine. However, I would like the player to hit the side of the wall and just fall straight down, instead of falling through. Is this possible?
  4. GROUP VS GROUP Sprite will be generated after 3 seconds with velocity.x randomly, but when the sprite generated with slow velocity.x and another new sprite will generate after 3 seconds. The problem is that I cannot collide with the previous sprite that generated with slow velocity. What is my problem? Can anyone please kindly correct me? I hope that someone helps me . Thanks ! create: function() { groupPlayer = game.add.group(); groupPlayer.enableBody = true; player = groupPlayer.create(game.world.centerX - 115, game.world.centerY, 'bananaBounce'); game.physics.arcade.enable(player); player.body.fixedRotation = true; player.body.gravity.y = 1000; player.body.collideWorldBounds = true; player.body.checkCollision = true; player.body.setSize(100, 50, 8, 10); player.animations.add('play'); player.animations.play('play', 25, true); player.smoothed = true; player.anchor.set(0.5); groupPlayer.add(player); game.time.events.loop(Phaser.Timer.SECOND * 3, this.randomSprite, this);},randomSprite: function() { imgRandomGroup = game.add.group(); imgRandomGroup.enableBody = true; imgRandomGroup.physicsBodyType = Phaser.Physics.ARCADE; var imgType = Math.floor(Math.random()*5); sprites = imgRandomGroup.create(game.world.width, game.rnd.between(40, 300), 'level1'); sprites.animations.add('anim', [imgType], 10, true); sprites.animations.play('anim'); game.physics.arcade.enable(sprites); sprites.events.onOutOfBounds.add(this.removeSprite, this); sprites.body.velocity.x -= 50 + Math.random() * 300; imgRandomGroup.add(sprites); },removeSprite: function(sprite) { sprite.kill(); },killSprite: function(sprite) { sprite.kill();},update: function() { game.physics.arcade.collide(imgRandomGroup, groupPlayer, this.killSprite, null, this);}
×
×
  • Create New...