Search the Community

Showing results for tags 'sprite group'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 3 results

  1. couple of questions

    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 =; 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: 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.
  2. Player collide with floor sides?

    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.floorPool, nextPlatformData.numTiles, + nextPlatformData.separation, nextPlatformData.y, -this.levelSpeed, this.coinsPool, this.enemiesPool, this.enemySprite, this.player, false); } else { this.currentPlatform.prepare( nextPlatformData.numTiles, + 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(, 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?
  3. collide group sprite problem

    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 =; groupPlayer.enableBody = true; player = groupPlayer.create( - 115,, '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');'play', 25, true); player.smoothed = true; player.anchor.set(0.5); groupPlayer.add(player); * 3, this.randomSprite, this);},randomSprite: function() { imgRandomGroup =; imgRandomGroup.enableBody = true; imgRandomGroup.physicsBodyType = Phaser.Physics.ARCADE; var imgType = Math.floor(Math.random()*5); sprites = imgRandomGroup.create(, game.rnd.between(40, 300), 'level1'); sprites.animations.add('anim', [imgType], 10, true);'anim'); game.physics.arcade.enable(sprites);, 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);}