Adam West

Members
  • Content count

    12
  • Joined

  • Last visited

  1. How to set collision between player and group of tiles?

    @oobarbazanoo try creating the group of tiles this way group = game.add.physicsGroup(); i'm not sure if it's the same than: me.platforms = me.game.add.group(); me.platforms.enableBody = true; but try anyway
  2. How to check [EASY]

    I'm not sure if this is the best approach but try this: this.game.physics.arcade.overlap(this.bullets, this.groupOfEnemies, this.bulletsColision, null,this); function bulletsColision(bullets, enemy) { console.log( this.groupOfEnemies.getIndex(enemy) ); }
  3. Sprite size problems

    That worked perfectly @samme, i will take a look at what you said anyway @jonteferm. Thks both for the answer.
  4. Sprite size problems

    You can see what i meant above here https://n3s7or.github.io/DoGGer/
  5. Try my flappy bird game

    It looks good as some has mentiones but i couldn't be able to score more than 3
  6. Sprite size problems

    I created a Texture Atlas using SpriteSheet Packer and I thoght it will crop the sprites but when i debug it showing the bounds i get what you can see in one of the pics attached, but when you look at the texture file the sprites are cropped, I dont know if that's a problem with frame dimensions in the json definition or not. Is there a way to do that without editing all the images to the proper dimensions?
  7. Sprites animation & gen paint

    Hi, for those who want to create graphics faster and easyly using that simple tool called Gen-Paint, check out below this function i made that allows to create and add a spritesheet dynamically to our game cache using the arrays of pixel data generated in Gen-Paint. Just copy the function in your project, the function will be called using the line generated in the modified version of gen-paint attached (An example is also attached). function createSpriteSheet(gameObj, frames, spritesheet_name){ var id_base = "texture_base_id_"; var objs = {n:frames.arrFrames.length,width:null,height:null}; for (var x = 0; x < objs.n; x++){ frames.arrFrames[x] = gameObj.create.texture(id_base+x,frames.arrFrames[x],frames.fWidth,frames.fHeight,0); } objs.width = frames.arrFrames[0].width; objs.height = frames.arrFrames[0].height; var bitmap = gameObj.add.bitmapData(frames.fWidth * objs.n * objs.width,frames.fWidth * objs.height); var x = 0; for (var i = 0; i < objs.n ; i++){ bitmap.draw(id_base+i, x, 0); x += objs.width; } game.cache.addSpriteSheet(spritesheet_name, '', bitmap.canvas, objs.width, objs.width); } gen_paint_1.js example.html
  8. Sprites animation & gen paint

    Browsing the site I found this thread http://www.html5gamedevs.com/topic/8258-create-animation-dynamically/, the author was looking for something similar, read it if you want, anyway one of the replies was so f.. helpful it almost has everything, i just need to do a few changes to my purpose. Basically what i did was create a spritesheet dynamically using the textures made by game.create.texture(), and then use it to create the animation. What we need to do is 1- Create the textures from the frames made using gen-paint. 2- Create the BitmapData Object (4 more info about it read the API docs) which will hold the spritesheet 3- Draw the sprites in the BitmapData object and add it to the cache 4- Create the player, animations, ...... See the file attached containing the whole example walking_guy.js
  9. Sprites animation & gen paint

    I see your point squilibob, but when i added the two functions and called them ir rises an error ReferenceError: FrameData is not defined. Besides this i'm not sure about one thing the third parammeter received by createAnimation(animationName, playerName, frameName) and then passed to createFrameData(frameName) isnt a frame but an array of characters. The code below is what i have so far for testing purposes. There it's shown the four textures and you can move one located in the middle of the screen. var game = new Phaser.Game(400, 300, Phaser.AUTO, '', { init : init, create : create, update : update}); // Frames var frame0 = [ // idle '.....33333......','....3333333.....','.....7D7D7......','....6777776.....', '.....77477......','......222.......','....2222222.....','....7222227.....', '....7222227.....','....7222227.....','....7001007.....','....7DDDDD7.....', '....76D.D67.....','.....DD.DD......','.....DD.DD......','.....55.55......']; var frame1 = [ // walk1 '.....3333.......','.....333333.....','....6667D7......','....6767777.....', '.....7777.......','.....222........','....2222........','....72222.......', '...677222.......','..76.2722.......','.....0070.......','.....DD.D.......', '....DDD.DD......','..5DDDD.DDD.5...','...5DDD.DDD5....','....55...55.....' ]; var frame2 = [ // walk2 '.....3333.......','.....333333.....','....6667D7......','....6767777.....', '.....7777.......','......222.......','.....22222......','.....722227.....', '.....722227.....','.....722227.....','.....70000......','.....7DDDD......', '......DDDD......','......DDDD......','......5..5......','......55.55.....']; var frame3 = [ //walk3 '.....3333.......','.....333333.....','....6667D7......','....6767777.....', '.....7777.......','.....222........','....222277......','...77222277.....', '...7.2222.77....','..7..2222.......','.....0000.......','.....DDDD.......', '....DDD.DD......','..5DDDD.DDD.5...','...5DDD.DDD5....','....55...55.....']; // ----------------------------- // Declaration var player = null; var cursor = null; // Phaser functions function init() {game.scale.pageAlignHorizontally = true; } function create(){ game.physics.startSystem(Phaser.Physics.ARCADE); cursor = game.input.keyboard.createCursorKeys(); // Show three textures on the screen 4 demonstration purpose var style = { font: "14px Arial", fill: "#ff0044", align: "center" }; var text = game.add.text(10, 10, "Textures created:", style); text_idle = game.create.texture('idle', frame0, 4, 4, 0); text_walk1 = game.create.texture('walk1', frame1, 4, 4, 0); text_walk2 = game.create.texture('walk2', frame2, 4, 4, 0); text_walk3 = game.create.texture('walk3', frame3, 4, 4, 0); game.add.sprite( 10, 30, 'idle' ); game.add.sprite( 60, 30, 'walk1' ); game.add.sprite( 110, 30, 'walk2' ); game.add.sprite( 160, 30, 'walk3' ); //------------------------- // Here goes the how to do animation player = game.add.sprite(game.world.centerX, game.world.centerY, 'idle'); player.anchor.setTo(0.5); //------------------------- game.physics.arcade.enable(player); player.body.collideWorldBounds = true; } function update() {movePlayer();} //---------------- // Other functions function movePlayer() { if (cursor.right.isDown) { player.body.velocity.x = 180; // Animation } else if (cursor.left.isDown) { player.body.velocity.x = -180; // Animation mirrored } else { player.body.velocity.x = 0; } }
  10. Sprites animation & gen paint

    Hi everyone. I'm just startig to learn phaser and so gamedev programming. I've seen some tutorials about basic stuff in phaser and now I think I should make - or try to - an "easy" arcade game like Paratrooper. I was thinking to use silly graphics created like below. var frame0 = [ .... ]; var frame1 = [ .... ]; var frame2 = [ .... ]; this.game.create.texture('idle', frame0, 4, 4, 0); this.game.create.texture('walk1', frame1, 4, 4, 0); this.game.create.texture('walk2', frame2, 4, 4, 0); this.player = this.game.add.sprite(this.game.width/2, this.game.height/2, 'idle'); So ... my question here is how do do animations using the textures created like that, because this way i'll have 3 different images/sprites, not like in spritesheets or atlases. So far I haven't found a way to do that or i don't know if to do that can be possible.
  11. Learn Phaser for beginners! (Spanish)

    hola, veo que hace ya dos años no actualizan este hilo, me gustaria saber la situacion actual de los tutoriales para personas de habla hispana hi, i can see this thread hasnt been updated since almost 2 years now, i'd like to know the current state of tutorials for spanish speakers