Search the Community

Showing results for tags 'phaser2'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

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 29 results

  1. Hello, I`m just getting started with game development and I`m trying to make a copy of Tetris that can be played on mobile phone as well. I want to be able to move the blocks with left/right/up arrows(from keyboard) and with 3 buttons that are displayd on the screen. Here I`m declaring the buttons(inside create function): create: function(){ //.... rotate_bricks = this.add.button(350, 180, 'rotate-shape', Tetris.Blocks.rotate, this); left_arrow = this.add.button(345, 240, 'left-arrow', Tetris.Blocks.moveLeft, this); right_arrow = this.add.button(345, 300, 'right-arrow', Tetris.Blocks.moveRight, this); //... }, And here is the moveLeft function: Tetris.Blocks = { moveLeft: function(game) { let points = 0; /*make a local variable, if all of the 4 blocks can be moved 30 px left/right then move it, if some of them will get out of the box, then don`t move Test for all blocks available on the map */ for(let i = 0; i < Tetris.allBlocks.children.length; i++) { //test if blocks collide with each others for(let j =0 ; j < Tetris.allBlocks.children[i].children.length; j++) { if(!(Tetris.allBlocks.children[i].children[j].body.velocity.y === 0) || Tetris.allBlocks.children[i].children[j].body.y > 370) { if(Tetris.allBlocks.children[i].children[j].body.x - 30 > 0) { points++; } else { break; } } } } for(let i = 0; i < Tetris.allBlocks.children.length; i++) { //test if blocks collide with each others for(let j =0 ; j < Tetris.allBlocks.children[i].children.length; j++) { if(!(Tetris.allBlocks.children[i].children[j].body.velocity.y === 0) || Tetris.allBlocks.children[i].children[j].body.y > 370) { if(points === 4) { console.log(Tetris.allBlocks.children[i].children[j].body.x);//for test Tetris.allBlocks.children[i].children[j].body.x = Tetris.allBlocks.children[i].children[j].body.x - 30; console.log(Tetris.allBlocks.children[i].children[j].body.x); } else { break; } } } } console.log("moved left"); }, the problem is that the console.log function is executed but the position isn`t changed(I know it works because when I use the keyboard everything is fine, I call the same function) The variable Tetris.allBlocks is declared globally(inside Tetris.Game as: var Tetris.allBlocks = ...); What it`s wrong? I couldn`t find an answer online
  2. traxtrack

    Issue with Obstacle velocity

    Hello, I have an issue which keeps me stuck and I could not yet figure it out after being stuck for quite some time. I have a simple game in which obstacles ( spirtes of other cars) drop down from the top of the screen and I am trying to avoid those with my own car not to crash into them. The issue is that on some mobile devices the cars drop WAY faster than on my own device, I tested this from several different phones, the velocity differs depending on the phone, on some the obstacles drop faster on some they drop really slow. What oculd cause such an issue? I can provide code if it helps. Thanks,
  3. Hi, Is it relevant to apply a pooling system to Phaser's Tweens in optic to reduce the garbage collector invocation ? Because this subject as already been asked but dont find a clear answer : Thanks
  4. Hello! I am trying to make a player to collide with the ground. But the ground has been imported from a tilemap using the tiled program. The collision is not working This is the important part of my code: collisionLayer = map.createStaticLayer('collisionLayer', tileset); var players = findObjectsByType('player', map, 'objectsLayer'); player = this.physics.add.sprite(players[0].x, players[0].y, 'dude'); this.physics.add.collider(player, collisionLayer); findObjectsByType is not a phaser native method, but it is working. The code runs without errors, but the collision is not working. I have attached the code. Thanks! example.zip
  5. Question about keyboard controls. I'm working on a simple action game in Phaser CE, the player touches certain parts of the screen to do various actions. The mouse/touch input parts work fine and now I also want to support keyboard input for people playing on desktop. The problem is; the game is running inside an iframe and the keyboard input works correctly until the canvas loses focus. The game pauses which is correct behaviour, then I click inside canvas again, game continues and mouse input still works. But now the keyboard input is not working anymore. When the game is not running inside an iframe this is not a problem, the keyboard continues to work after losing focus, pausing and then continuing. Do I have to use something other than "game.input.keyboard.addCallbacks" to check for keyboard input? This is my code mygame.GameState.prototype = { create: function() { this.stage.backgroundColor = "#f0f"; this._levelindex = 0; // .. // etc. // game input for mouse and keyboard this.game.input.onDown.add(this.onGameMouseDown, this); // mouse/touch this.game.input.keyboard.addCallbacks(this, this.doGameKeyInput, null, null); // keyboard // .. }, onGameMouseDown: function(evt) { // code.. ok works fine }, doGameKeyInput: function(key) { var kc = key.keyCode; var action = 0; if (kc == 32) {action = 1}; // space if (kc == 90) {action = 2}; // Z if (kc == 88) {action = 3}; // X // etc. this works until canvas loses focus } } FYI i'm using Windows 10 and Chrome
  6. Kiwi404

    Reuse Emitter, bug or bad use ?

    Hi, Is there any method to reset an emitter properly to be reused ? because i reuse a set of emitters but sometimes when i reuse a previously used emitter it show quickly his last state (repartition of particules in their last coordinates) and then restart his animation, so i wonder if is it a bug or a bad use. EDIT : It's a bad. Code used to instanciate the emitters in the poolEmitter (extended Phaser.group) instance : em = game.add.emitter(10,16,30) // some emitter settings (minRotation, setXSpeed,makeParticles...) em.kill() this.add(em) Code used in the poolEmitter instance to get a free (dead) emitter : let obj = this.getFirstDead(false) obj.revive() obj.x = x obj.y = y return obj Code used for exploitation of the emitter : let em = poolEmitter.create(player.x ,player.y) em.explode(800,30) setTimeout(function(){ em.kill() em.on = false em.visible = false /* em.forEach(function(p) { // I try this to hide the particule manually to avoid to be showed in their last coord when reuse the emitter, but dont work p.alpha = 0 })*/ },900) Thanks
  7. help in my game I eliminate an enemy with enemy.kill () and deasa appears but the associated weapon keeps firing .. and enemy.destroy () gives me an error ..
  8. Play Cool Math

    Math Mahjong Relax

    Welcome to online Math Mahjong Relax. Math Mahjong Relax is a traditional solitaire game where you have to take apart the construction made of dice. The game helps to improve your attention, speed and math skills. Dice differ in the image on the upper edge. With one move, you can get only two same and open dice. The dice is considered open if its left or right face is open. The game includes 36 levels from simple to complex ones. In the beginner levels you will learn the rules, find out which dice differ and which ones can be interchangeable. Online Math Mahjong Relax iOS Math Mahjong Relax Android Math Mahjong Relax
  9. Hello! I want to use method BringToTop for layer data item. But it doesnt work for me. I have some layers, and i want to hide my character behind some sprites. I need something like that: But i have got it: Here is my code: this.parent.Location.location = this.parent.game.add.tilemap('map'); if (!this.parent.Location.props.images) { console.error('Images are empty or undefined read readme.md for information'); return false; } _.each(this.parent.Location.props.images, (layer, index) => { this.parent.Location.location.addTilesetImage(layer.name, layer.name); this.parent.Location[layer.layer] = this.parent.Location.location.createLayer(layer.layer); this.parent.Location[layer.layer].resizeWorld(); if (_.size(layer.bringToTop)) { this.bringToTop(index, layer.bringToTop); // 0, [6,7] } }); bringToTop(index, bringToTopArray) { let gid = this.parent.Location.location.tilesets[index].firstgid; _.each(bringToTopArray, (itemBring) => { _.each(this.parent.Location.location.layers[index].data, (layerData) => { _.each(layerData, (layerDataItem) => { if ((itemBring + gid) === layerDataItem.index) { let timeAfterLoad = this.parent.game.time.events.add(0, () => { this.parent.game.world.bringToTop(layerDataItem); this.parent.game.time.events.remove(timeAfterLoad); }); } }); }) }); } If you know another ways how i can resolve that problem, let me know please.
  10. Doug

    Hi Rich.  @rgk mentioned that you might be able to please add a "patron" badge to my forum profile?  Thanks very much!

  11. Finwillwin

    Animation Problem

    Here is my issue: Uncaught TypeError: Cannot read property 'getFrameIndexes' of null at i.AnimationManager.add (phaser.min.js:3) at Object.create (hub.js:45) at i.StateManager.loadComplete (phaser.min.js:3) at i.StateManager.preUpdate (phaser.min.js:3) at i.Game.updateLogic (phaser.min.js:3) at i.Game.update (phaser.min.js:3) at i.RequestAnimationFrame.updateRAF (phaser.min.js:3) at window.requestAnimationFrame.forceSetTimeOut._onLoop (phaser.min.js:3) Here is my code: if(game.spawn == 0){ player = game.add.sprite(500, 800, 'guy'); } else if(game.spawn == 1){ player = game.add.sprite(1700, 1002, 'guy'); } horn = 0; player.scale.setTo(1,1); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; up = game.input.keyboard.addKey(Phaser.Keyboard.W); down = game.input.keyboard.addKey(Phaser.Keyboard.S); left = game.input.keyboard.addKey(Phaser.Keyboard.A); right = game.input.keyboard.addKey(Phaser.Keyboard.D); y = game.input.keyboard.addKey(Phaser.Keyboard.Y); n = game.input.keyboard.addKey(Phaser.Keyboard.N); f = game.input.keyboard.addKey(Phaser.Keyboard.F); f.onDown.add(hub.gofull, this); q = game.input.keyboard.addKey(Phaser.Keyboard.Q); q.onDown.add(hub.show, this); game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT; game.camera.follow(player, Phaser.Camera.FOLLOW_LOCKON, 0.1, 0.1); player.animations.add('right', [14,16], 6, true); player.animations.add('left', [20,22], 6, true); player.animations.add('down', [2,4], 6, true); player.animations.add('up', [10,8], 6, true);
  12. Hello, I am working on a project where i can drag an object in X-direction only(like in a abacus). Is it possible to drag objects in one direction only? I created a simple task where i can move two objects with mouse (link here). The issue is that objects are pushing inside each other if i drag one object to another. I need them to be hard like diamond. Can i achieve that with p2 js or i have to use box2d plugin (like here). Also is box2d will be availabe in phaser v3. Thanks
  13. Всем привет! Если мы напишем let enabled = this.game.renderer.setTexturePriority(['UIAtlas', 'InGameAtlas']); в первом состоянии текстуры отображаются нормально. При изменении состояния. this.game.state.start('InGame'); текстуры исчезают. https://prnt.sc/jbcdz0 информация об отладке https://prnt.sc/jbcdz0 в чем проблема? Благодаря!
  14. I'm trying to zoom camera (change its scale) while focused on a player on a tilemap. const speed = 0.01; if (this.cursors.up.isDown) { this.game.camera.scale.add(speed, speed); } else if (this.cursors.down.isDown) { this.game.camera.scale.add(-speed, -speed); } This is how I create the map: this.map16 = this.game.add.tilemap("tilemap16"); this.map16.addTilesetImage("xrpg_tileset", "tileset16"); this.wallsLayer = this.map16.createLayer('Walls'); Both player object and the map layers are placed in the World. But it seems that tilemap layer's position is affected by camera's zoom which looks wrong: https://gph.is/2HuEeDk To check if something is wrong with the scene I replaced the map with an image and zoom worked correctly: https://gph.is/2KitDZL The behaivor is identical in 2.6.2 and 2.10.3.
  15. CodePen I feel confusing when i use Tween.from. Using Tween.from without repeat param the animation shows correctly.It move from (100,0) to (0,0).But when i use Tween.from with repeat param. The repeat is from (0,0) to (100,0).Why?I think it would repeat always from (100,0) to (0,0)
  16. I am learning Phaser CE API and i cannot understand the param `alphaThreshold` in the method enableDrag. Anybody can tell me how to use it correctly?
  17. Hey, So I am working on a car game and I have 1 issue with the speed at which car drops. My friend who owns a IPhone s6 complains that on his device the cars drop too fast, while on my Samsung s7 edge the car seems to drop slow enough. I dont know what might cause it. My obstacle velocity is set to 1200; // OBSTACLES vars var obstacleSpeed = 1200; var obstacleDelay = 400; var platforms; var score; And this is my Loop + update function // OBSTACLES OF THE CAR game.time.events.loop(obstacleDelay, function(){ var obstacleSpeed = 1200; var obstacleDelay = 400; for(var i = 0; i < 1; i++){ if(game.rnd.between(0, 1) == 1){ var obstacle = new Obstacle(game, i); obstacle.scale.setTo(scaleRatio, scaleRatio); game.add.existing(obstacle); obstacleGroup.add(obstacle); } } }); // Game on touch move car game.input.onTap.add(function() { if (game.input.x < w / 2 ){ if( canMove && goleftonce == 2 || goleftonce == 1) { canMove = false; goleftonce++; gorightonce--; game.add.tween(car).to({ angle: -30}, 100, Phaser.Easing.Linear.None, true).onComplete.addOnce(function(){ game.add.tween(car).to({ angle: 0}, 100, Phaser.Easing.Linear.None, true); canMove = true; }, this); game.add.tween(car).to({x: car.x - w/3}, 100, Phaser.Easing.Linear.None, true); } } else { if( canMove && gorightonce == 2 || gorightonce == 1) { canMove = false; goleftonce--; gorightonce++; game.add.tween(car).to({ angle: 30}, 100, Phaser.Easing.Linear.None, true).onComplete.addOnce(function(){ game.add.tween(car).to({ angle: 0}, 100, Phaser.Easing.Linear.None, true); canMove = true; }, this); game.add.tween(car).to({x: car.x + w/3}, 100, Phaser.Easing.Linear.None, true); } } }); }, update: function() { // Collide the car and with the obstacles aka other cars game.physics.arcade.collide(car, obstacleGroup, function(){ canMove = true; countcars = 0; goleftonce = 2; gorightonce = 2; game.state.start('gameover'); }); } } // Position where the obstacle spawns Obstacle = function (game) { var position = game.rnd.between(0, 2); Phaser.Sprite.call(this, game, (w/3) * position + 130 , 0, "obstacle"); game.physics.enable(this, Phaser.Physics.ARCADE); }; Obstacle.prototype = Object.create(Phaser.Sprite.prototype); Obstacle.prototype.constructor = Obstacle; Obstacle.prototype.update = function() { this.body.velocity.y = obstacleSpeed; if(this.y > game.height){ countcars++; score.setText("Score: " + countcars); this.destroy(); } };
  18. Hemanthraj

    How to smooth tween animation

    How to smooth the tween animation in the android devices.
  19. Hey all, I'm using tween for my game in the android device it is too lacking and slowly working tween, then i tried with physics both too slow how to solve.
  20. Hemanthraj

    How to detect if tab is not active

    How to detect if current window tab is not active in the phaser
  21. SirFizX_ELHS

    Huntin and Fishin

    This is something I put together this afternoon for my students to play with. Live demo.
  22. ZyMonogatari

    Sprites are overlapping on collide

    Hello, Im making a game where you have to jump some cars, you only lose if you touch the left side of a car. the problem is when the character lands over a car both sprites overlap, and if another car comes behind you will collide with it instead of pass over it I'm using arcade physics. I'll let you a couple screenshoots of this. Is there some way to avoid this?
  23. Hemanthraj

    how to make number tiles

    How to make number tiles with colors for example: array[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; I need to show into these box
  24. Hey I am planning to create web game pages by using Phaser2. My project will be used Phaser2, Java, jsp and Oracle DB (maybe Node.js) I want to make this game Multiplayable, so I decide to get web hosting service but I can't find proper hosting service site. What is the proper hosting site in my project conditions??
  25. onlycape

    Touch screen problem in Kongregate

    Hi, I just uploaded a game made with on Kongregate to its own server (using the option webgl/html5): https://www.kongregate.com/games/olycape/flappy-tours In the game I use the onDown event: game.input.onDown.add (this.myfunction, this); In the free server where I have it hosted everything works correctly: http://jjgames.pcriot.com/ The problem is that on touch screens and only on the Kongregate website, raising your finger generates the onDown event. Due to this the control becomes very difficult in touch screens. From what I see the game is embeded in an iframe from one of its servers. I would like to avoid the use of onTap, since it is not very agile for this type of game. Has anyone else had this issue? Any advice?. Thanks in advance. Regards.