Search the Community

Showing results for tags 'phaser'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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 2,858 results

  1. Tweening particles

    Hey all. I want to apply color tweening to particles, but i don't know how, can anybody help me in this? thanks in advance
  2. Impossible Snake is a game I've been working on (see posts here and here) and it's now available on the Android playstore. Impossible Snake on Android Store: https://play.google.com/store/apps/details?id=com.bdrgames.impossiblesnake.ads Impossible Snake on kongregate - http://www.kongregate.com/games/BdRGames/impossible-snake Impossible Snake on newgrounds - http://www.newgrounds.com/portal/view/698543 It is a one-button game, meaning that you control the snake with only single taps on the screen. Every time you tap the snake will toggle between turning clockwise and counter-clockwise. Eat all apples to complete a level, the last three levels are almost impossible.. almost. There is also a VS multiplayer mode, where 2 players can compete on the same device. Player one taps on the top half and player two taps on the bottom half to control their snake. Eat the most apples to win.
  3. Creating a slot game

    So I'm practicing Phaser by creating a slot machine, I've got most of it down but I'm having some issues with getting the reels to move and stop randomly. Here is my current code: <!DOCTYPE HTML><html> <head> <meta charset="UTF-8"/> <title>Slots </title> <script src="phaser.min.js"></script> </head> <body> <script type="text/javascript" > window.onload = function () { var game = new Phaser.Game(640,480, Phaser.CANVAS, 'd',{ preload: preload, create: create, update: update }); var seven; var bar; var twobar; var cherry; var cherry2; var tween; var spinning = false; var timer; var tick = 0; var reel1; var reel2; var reel3; var reel4; function preload() { // Pre load all images. //Cherry game.load.image('cherry', 'img/cherry.png'); // Bar game.load.image('bar', 'img/bar.png'); // TwoBars game.load.image('twoBar', 'img/twobar.png'); //seven game.load.image('seven', 'img/seven.png'); // Spin Button game.load.image('spin_button', 'img/spin_button.png'); // Machine_body game.load.image('machine_body', 'img/machine__body.png'); } function create() { var items = ['cherry', 'bar', 'seven', 'twoBar', 'cherry', 'bar', 'seven', 'twoBar']; reel1 = game.add.group(); // first reel. reel2 = game.add.group(); reel3 = game.add.group(); reel4 = game.add.group(); for(var i = 0; i < 5; i++) { sprite = reel1.create(5, i * 98 +3, items[game.rnd.integerInRange(0,5)]); sprite2 = reel2.create(131, i * 98 +3, items[game.rnd.integerInRange(0,5)]); sprite3 = reel3.create(258, i * 98 +3, items[game.rnd.integerInRange(0,5)]); sprite4 = reel4.create(386, i * 98 +3, items[game.rnd.integerInRange(0,5)]); } var body = game.add.sprite(0,0, 'machine_body'); var button = game.add.button(175, 400,'spin_button', actionOnClick, this); game.stage.backgroundColor = '#FFFFFF'; timer = game.time.create(false); timer.loop(3000, updateTicks, this); timer.start(); } function actionOnClick () { spinning = true; } function update() { if(spinning) { reel1.y += 50 reel2.y += 40; reel3.y += 57; reel4.y += 60; if(reel1.y >= 400){ reel1.y = 0; } if(reel2.y >= 400){ reel2.y = 0; } if(reel3.y >= 400){ reel3.y = 0; } if(reel4.y >= 400){ reel4.y = 0; } } var tween = game.add.tween(reel1); var tween2 = game.add.tween(reel2); var tween3 = game.add.tween(reel3); var tween4 = game.add.tween(reel4); tween.to({y: 180}, 60); tween2.to({y: 180}, 70); tween3.to({y: 180}, 80); tween4.to({y: 180}, 90); tween.start(); tween2.start(); tween3.start(); tween4.start(); } function updateTicks() { if(spinning){ spinning = false; } } } </script> </body></html> The idea is to have each reel as a group move down until it hits a threshold and then return to 0, after a timer expires it will tween to a stop with the closest element to the middle. The issue I have with this is that the final tween always seems to move the top element to the position rather than the closest element which is what I assume happens to a real slot machine leaving a gap on the top of the reel (see attached image). Assistance on getting each reel to move randomly and sorting out my button would also be great Thanks!
  4. Wedding Run (open source)

    Hi All! Intro As a front-end developer it was a MUST to create an online HTML5 game for our wedding website I've recently discovered Phaser and I was amazed by the things you can achive with it. The Phaser community is just awesome, I've got a lot of help from forums, examples and tutorials I've found during the development. I would like to give something back to the community. That's one of the reasons I've published the source code of the game. The game Wedding Run is an endless 2D platform game. You can play either with the groom or with the bride. The long as you will survive the more points you can achieve. Killing bunnies and collecting coins can raise your score! Have phun! Try it Try it online at http://www.zsondre.hu/wd/ Check out the source code at https://github.com/aendre/wedding-run
  5. Particle collision

    i'm trying to change collision option after emitter had started but i can't create () { // --------------------------------CONFIG-------------------------------- this.config = { 'followCursor': false, 'mouseClick': false, 'gravityX': 0, 'gravityY': 0, 'positionX': 960, 'positionY': 540, 'maxParticles': 50, 'particleKey': 'particle', 'frames': 1, 'quantity': 5000, 'collide': false, 'collideWorldBounds': false, 'scaleToX': 1, 'scaleToY': 1, 'scaleRate': 0, 'scaleEase': Phaser.Easing.Linear.None, 'scaleYoyo': false, 'alphaMin': 1, 'alphaMax': 0, 'alphaRate': 0, 'alphaEase': Phaser.Easing.Linear.None, 'alphaYoyo': false, 'rotationMin': 0, 'rotationMax': 0, 'bounceX': 0, 'bounceY': 0, 'angularDrag': 0, 'particleMinSpeedX': -300, 'particleMinSpeedY': -300, 'particleMaxSpeedX': 300, 'particleMaxSpeedY': 300, 'emitterSpeedX': 200, 'emitterSpeedY': -200, 'lifespan': 500, 'particleFrequency': 250, 'particleQuantity': 500 } // --------------------------------EMITTER-------------------------------- this.emitter = this.game.add.emitter(this.config.positionX, this.config.positionY, this.config.maxParticles) this.makeParticles() this.emitter.minParticleSpeed.setTo(this.config.particleMinSpeedX, this.config.particleMinSpeedY) this.emitter.maxParticleSpeed.setTo(this.config.particleMaxSpeedX, this.config.particleMaxSpeedY) this.emitter.gravity.x = this.config.gravityX this.emitter.gravity.y = this.config.gravityY this.emitter.setScale(this.config.scaleFromX, this.config.scaleToX, this.config.scaleFromY, this.config.scaleToY, this.config.scaleRate, this.config.scaleEase, this.config.scaleYoyo) this.emitter.setAlpha(this.config.alphaMin, this.config.alphaMax, this.config.alphaRate, this.config.alphaEase, this.config.alphaYoyo) this.emitter.angularDrag = this.config.angularDrag this.emitter.setRotation(this.config.rotationMin, this.config.rotationMax) this.emitter.bounce.setTo(this.config.bounceX, this.config.bounceY) this.emitter.setXSpeed(this.config.emitterSpeedX) this.emitter.setYSpeed(this.config.emitterSpeedY) this.startEmitter() // here I want to change both collision options from false to true, and to make it work with new collision options } startEmitter () { this.emitter.start(false, this.config.lifespan, this.config.particleFrequency, this.config.particleQuantity, false) } makeParticles () { this.game.add.emitter(this.config.positionX, this.config.positionY, this.config.maxParticles) this.emitter.makeParticles(this.config.particleKey, this.config.frames, this.config.quantity, this.config.collide, this.config.collideWorldBounds) } Can anybody help me in this?
  6. A.I Egg

    So, just a little project created while building a few functions and stuff I'll need for later projects. Turned out pretty good for what I wanted, but later I'll go back to improve a few more things. A bit too plain right now, but gets the job done. Play in the browser, mobile or desktop: http://umzgames.com/itcn/aiegg
  7. I am new to Phaser and have made two slightly different versions of the Cat Catcher demo from Travis Faas's Phaser book. https://preview.c9users.io/srjcdt/srjc/module02/index.html https://preview.c9users.io/srjcdt/srjc/module02/index_bak1.html In index.html there is a visual artifact in the "catcher" (player) object in which the game displays the edge pixels from the catcher's net in front of the player. You can see it against the background hill in the upper right. It happens sometimes, but not all the time. You may have to flip back and forth a bit before you can see it. This does not seem to happen in index_bak1.html. The only significant difference that I can see between the two games is that the movement speed was changed from an integer to a decimal number (5.5px). Differences: (excluding comments) https://preview.c9users.io/srjcdt/srjc/module02/diffs.txt I upgraded locally to Phaser 2.8.5 and still see the issue. I could probably work around this by increasing the width of the character by one and leaving a column of empty pixels between the frames, but it looks like there might be a display bug in some subsystem of Phaser.
  8. Phaser+Nodejs+MongoDB+Requirejs

    A friend of mine and myself just recently graduated from the Ironyard(a full-stack web development boot camp) and have begun work on our final project, choosing to do a game through Phaser. My friend had already begun work on the game and had it working, but not to the scale we wished to bring it. The end goal was to use Nodejs to navigate through a login, sign up, and game page, saving the user info(as well as the game state) to a mongoose/mongodb. We also wanted to use socket.io to make it multiplayer, working on mobile and desktop. In its state before beginning this endevour, it had six game states(Boot, Preloader, MainMenu, level outside, level house) all as functions with prototypes, rendered by placing them in scripts in the head of the index.html file and then running a script to add all these to the game state manager on the windows load. link here https://github.com/AHarryHughes/Top-Down-Shooter/tree/master When we added the Node.js server, we had to add all the game and Phaser files to the static directory in nodejs, serving them up to the browser, the problem with this is that now we were unable to modularize the code. I attempted to utilize Requirejs but it can't seem to find my src file instead I just get an error reading "404 main.src not found" when my src="main.js" inside the script. That current code is here https://github.com/AHarryHughes/Top-Down-Shooter/tree/modPt3 I have also seen that browsers are starting to support type=module in scripts and am thinking this may be a path for better modularization of our game, but I'm looking for advice on the subject if anybody has experience using it. Another problem I see in the distance is saving the game to the MongoDB server, it is a wave based game utilizing tower defense and gun purchasing, so the only thing to save would be which wave, what tower is placed and where, as well as what guns the player has. I'm having trouble seeing how the phaser game will be able to communicate with the server. Any advice would be greatly appreciated, I'm new to this blog but I've gathered a lot of helpful information thus far from other posts on this subject, but it seems my problem might be a little more specific than any other posts I've read, if I'm wrong in this, a point in the right direction would help just as much, thank you.
  9. Hi All, I'm familiar with these technologies: JavaScript, AS3, Haxe, and have a lot of experience in multi-platform development. Several recent projects have been created using the Phaser framework, but I'm always open to new knowledge. Send me message or use email bestpositiveexperience@gmail.com Regards, Nikolai
  10. Phaser Web Components UI Plugin

    tl;dr: An HTML based UI component system for phaser. MIT License, and links to pretty pictures and videos at the bottom. So I have spent the last week or so working on a new way to handle ui components with Phaser. Most of the UI plugins out there are created with Phaser which means Phaser not only has to handle the game but the UI as well. Meaning that Canvas/WebGL has to handle both the game and ui. With other games platforms versus web games this is not an issue because performance is expected so the systems typically are beefier. With web games the games can be played on anything from an older tablet to an Lenovo Thinkpad to a raspberry pi. So the systems that these games can be played on can be lacking in power. As a developer you want your game to utilize as much of the accelerated GPU as possible. Chrome and other web browsers tend to offload Canvas and WebGL rendering to the GPU. While some aspect of html nodes, most of which are minimally impactful as opposed to the Phaser created ui components. This is where this plugin comes into play. Introducing Phaser Web Components. A growing library of HTML based elements to handle all of your UI needs. You can use your standard HTML elements to create your UI as well as use the custom components that are packaged as well. One of the great features is that you can attach these components to Phaser game objects and they will move with the objects on screen and the disappear when the object no longer is on screen. Already there is a lot of power with this library and it is barely a week old. First off, its free. Not just free to use but you can customize the library how you see fit with the MIT license. You can create your own custom components and if you wish to give back you may even create a pull request and share your work with everyone else. Also, each component has minimal dependencies and some only depend on the base web component which means you can build the library for your game and cut out any fat with ease. Documentation is a thing that it is currently lacking. However, with each control I release I update the wiki page for that control with the base code to get that component up and running. At the moment it is light but expect the documentation to grow over time. I am also at the constant keeping things up to date with the release chart so that way people can see what to expect with things coming down the pipeline. Also if you wish to see work done on a component that doesnt have a release date yet, to see if it can be focused on, or if you have a new idea for a component then you can request that through the issues tab in github. With all that, if you wish to see it in action, below are some links to screen captures of **some** of the components that are already working. GitHub link Damage Indicator Name Plate and Stat Bars Marker Window Volume bar Video Player Avatar Icon Screen Splatter Component improperly loaded
  11. [WIP][phaser] Micro challenge

    A reimagining of a popular micro challenge (1a2a3a micro) and my first attempt at game making. The player assumes the role of an A.I charged with defending the base from the incoming hostile enemies. He does so by switching between the three cannons with the hot keys 1,2,3 and then firing by A clicking on enemy units. The game still needs some major polish. Death animation removal is buggy, currently there are no unit shadows, I need a teleport animation for incoming units and I need to splice up the splash screen in order to animate it to make it loo more lively. It looks boring atm imo. What do you guys think?
  12. Hi ive been making a game with phaser and ive set out my game to have each game state a separate java-script and then loads the js file when it needs game.add.tween(BlackFade).to( {alpha: 1}, 100, "Linear", true ) console.log(BlackFade.alpha) if (BlackFade.alpha >= 0.9 ){game.state.start('endGame');} WebSocket connection to 'ws://localhost:8125/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED VM143:870 This is the error i get ^^
  13. [Phaser] Truck Reign

    Hello, This game was made with Phaser framework, P2 Physics, Howler.js, localForage, phaser-ads plugin and wrapped with CocoonJS Google Play: Truck Reign Itch.io: https://alex-creativity.itch.io/truck-reign YouTube: Truck Reign Any feedback would be greatly appreciated!
  14. I'm trying to get a start in Phaser but there seems to be no way to create sprites of any form without having a server or doing development locally. I was hoping to be able to host all my games on jsfiddle. If I need a server would it also be possible to use simple shapes as sprites?
  15. Phaser simple Game lags on mobile

    Hi, I am new to phaser as well as game designing. I created my first game as hobby using phaser. it is working fine in desktop but lags very bad on mobile devices. Images I am using for game is very small. game is smaller that 2mb. I am attaching my main.js file hope someone can help me. thanks var buttetSpwanSpeed; var bulletSpeed; var enemySpwanSpeed; var enemySpeed; var golis; var enemies; var enemyLoop; var scoreText; var powers; var bulletSize; setStart(); //game phaser var game=new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.WebGL,""); var BootState={ //loding accets preload: function(){ this.load.image('LodingScreen', 'assets/desimulga.png'); this.load.image('background', 'assets/blue.png'); }, create: function(){ game.state.start("LoadingState"); }, }; var LoadingState={ //loding acc preload: function(){ bg=this.game.add.tileSprite(0,0,600,300,'background'); bg.height = game.height; bg.width = game.width; LodingScreen=this.game.add.sprite(this.game.world.centerX,this.game.world.centerY,'LodingScreen'); LodingScreen.anchor.setTo(0.5); LodingScreen.scale.setTo(0.5,0.5); this.load.image('spaceship', 'assets/player.png'); this.load.image('goli', 'assets/bullet.png'); //load ememies this.load.image('enemy1', 'assets/enemies/enemy1.png'); this.load.image('enemy2', 'assets/enemies/enemy2.png'); this.load.image('enemy3', 'assets/enemies/enemy3.png'); this.load.image('enemy4', 'assets/enemies/enemy4.png'); this.load.image('enemy5', 'assets/enemies/enemy5.png'); this.load.spritesheet('power1', 'assets/power/bulletUp.png',34,33,4); this.load.image('restart', 'assets/restart.png'); this.load.spritesheet('blast', 'assets/explosion.png',400,400,8); game.load.audio('fire', 'assets/music/bullet.mp3'); game.load.audio('killed', 'assets/music/killed.mp3'); //game.load.audio('bg_music', 'assets/music/background.mp3'); game.load.audio('death_music', 'assets/music/death.mp3'); game.load.audio('start_music', 'assets/music/start.mp3'); }, create: function(){ game.time.events.add(Phaser.Timer.SECOND * 2, function(){ bg.kill(); LodingScreen.kill(); game.state.start("PreGameState"); },this); }, }; var PreGameState={ //loding accets create: function(){ game.scale.refresh(); bg=this.game.add.tileSprite(0,0,600,300,'background'); bg.height = game.height; bg.width = game.width; Startb=this.game.add.text(this.game.world.centerX,this.game.world.centerY, 'TAP TO START' , { fontSize: '32px', fill: 'yellow' }); Startb.anchor.setTo(0.5); Startb.scale.setTo(0.5,0.5); ship=this.game.add.sprite(this.game.world.centerX,this.game.world.height*0.4,'spaceship'); ship.scale.setTo(0.4); ship.anchor.setTo(0.5); game.physics.arcade.enable(ship); bg.inputEnabled=true; start_music = game.add.audio('start_music'); start_music.allowMultiple = true; start_music.addMarker('start_music', 0, 30); bg.events.onInputDown.add(function(){ bg.inputEnabled=false; Startb.kill(); start_music.play("start_music"); // game.physics.arcade.moveToXY(ship, this.game.world.centerX, this.game.world.height*0.8, 300, 3000); // game.add.tween(ship).to( { y: game.world.height*0.8 }, 3000, Phaser.Easing.Sinusoidal.InOut, true); var tween = game.add.tween(ship).to({ x: [this.game.world.centerX, this.game.world.width*0, this.game.world.width, this.game.world.centerX], y: [this.game.world.height*0.4, this.game.world.height*0.5, this.game.world.height*0.6, this.game.world.height*0.8], }, 2000,Phaser.Easing.Quadratic.Out, true).interpolation(function(v, k){ return Phaser.Math.bezierInterpolation(v, k); }); game.time.events.add(Phaser.Timer.SECOND * 2, function() { bg.kill(); ship.kill(); game.state.start("GameState"); } ,this); }, this); }, }; var GameState={ //loding accets preload: function(){ }, create: function(){ //background this.background=this.game.add.tileSprite(0,0,600,300,'background'); this.background.height = game.height; this.background.width = game.width; this.background.inputEnabled=true; this.background.input.enableDrag(true); this.background.input.startDrag = function(pointer) { pointer.shipStart = new Phaser.Point(GameState.ship.x, GameState.ship.y); Phaser.InputHandler.prototype.startDrag.call(this, pointer); }; this.background.input.updateDrag = function(pointer) { GameState.ship.x = pointer.shipStart.x - pointer.positionDown.x + pointer.x; GameState.ship.y = pointer.shipStart.y - pointer.positionDown.y + pointer.y; GameState.background.x=0; GameState.background.y=0; }; //ship this.ship=this.game.add.sprite(this.game.world.centerX,this.game.world.height*0.8,'spaceship'); this.ship.scale.setTo(0.4); this.ship.anchor.setTo(0.5); game.physics.arcade.enable(this.ship); // this.ship.inputEnabled=true; // this.ship.input.enableDrag(true); //score this.scoreText = this.game.add.text(16, 16, 'Kills: 0', { fontSize: '32px', fill: '#fff' }); //background Music // music = game.add.audio('bg_music'); //music.play('', 0, 1, true); //bullet sound bullet_sound = game.add.audio('fire'); bullet_sound.allowMultiple = true; bullet_sound.volume=0.5; bullet_sound.addMarker('fire', 0, 0.5); //Killed sound killed_sound = game.add.audio('killed'); killed_sound.allowMultiple = true; killed_sound.addMarker('killed', 0, 0.5); //death music death_music = game.add.audio('death_music'); death_music.allowMultiple = true; death_music.addMarker('death_music', 0, 10); //groups of bullets and enemies golis=game.add.group(); enemies=game.add.group(); powers=game.add.group(); //fire bullet loop fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/buttetSpwanSpeed, fireBullet, this); //this.game.input.onTap.add(fireBullet, this); //create ememy loop enemyLoop=game.time.events.loop(Phaser.Timer.SECOND*1/enemySpwanSpeed, createEnemy, this); //change ememy speed and enemy spwan speed loop enemySpeedLoop=game.time.events.loop(Phaser.Timer.SECOND*1.5, changeEnemySpeed, this); //give powerup powerUp=game.time.events.loop(Phaser.Timer.SECOND*20, powerFun, this); }, update: function(){ //scrolling background this.background.tilePosition.y+=2; //keybord control if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { this.ship.y-=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { this.ship.y+=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { this.ship.x+=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { this.ship.x-=2; } //dont go out if(this.ship.y<0+this.ship.height/2) { this.ship.y=0+this.ship.height/2; } if(this.ship.y>this.game.world.height-this.ship.height/2) { this.ship.y=this.game.world.height-this.ship.height/2; } if(this.ship.x<0+this.ship.width/2) { this.ship.x=0+this.ship.width/2; } if(this.ship.x>this.game.world.width-this.ship.width/2) { this.ship.x=this.game.world.width-this.ship.width/2; } //check for collisions game.physics.arcade.overlap(golis,enemies,b_e_collide,null,this); game.physics.arcade.overlap(this.ship,enemies,s_e_collide,null,this); game.physics.arcade.overlap(this.ship,powers,s_power1_collide,null,this); }, }; //setting start game conditions function setStart(){ buttetSpwanSpeed=2; bulletSpeed=2000; enemySpwanSpeed=1; enemySpeed=300; score=0; bulletSize=1.2 } //fire bullet function function fireBullet(){ goli=this.game.add.sprite(this.ship.x,this.ship.y-this.ship.height/2,'goli'); goli.anchor.setTo(0.5); goli.scale.setTo(bulletSize,1); goli.checkWorldBounds = true; goli.outOfBoundsKill = true; //adding to group golis.add(goli); game.world.moveDown(goli); game.physics.arcade.enable(goli); goli.body.collisonWorldBounds=true; goli.body.velocity.y=-bulletSpeed; bullet_sound.play("fire"); } //create enemy function function createEnemy(){ enemyNo=game.rnd.integerInRange(1, 5); x1=game.rnd.integerInRange(0,this.game.world.width); x2=game.rnd.integerInRange(0,this.game.world.width); enemy=this.game.add.sprite(x1,10,'enemy'+enemyNo); enemy.anchor.setTo(0.5); enemy.scale.setTo(0.4); enemy.checkWorldBounds = true; enemies.add(enemy); enemy.outOfBoundsKill = true; game.physics.arcade.enable(enemy); enemy.body.collisonWorldBounds=true; enemy.angle=90; enemy.no=enemyNo; //moving enemy angleRedian=game.physics.arcade.moveToXY(enemy, x2, this.game.world.height+enemy.height, enemySpeed,0); angleDegree=angleRedian*57.2958; enemy.angle=90+angleDegree; } //runs when bullet collide to enemy function b_e_collide(goli,enemy){ //blast blast=this.game.add.sprite(enemy.x,enemy.y,'blast'); blast.anchor.setTo(0.5); blast.scale.setTo(0.5); var explosion=blast.animations.add('explosion'); blast.animations.play('explosion',30,false,true); //killing goli.kill(); enemy.kill(); //update scores if(enemy.no<4) { score+=1; killed_sound.play('killed'); } this.scoreText.text = 'Kills: ' + score; } //runs when ship collide to enemy function s_e_collide(ship,enemy){ blast=this.game.add.sprite(enemy.x,enemy.y,'blast'); blast.anchor.setTo(0.5); blast.scale.setTo(0.5); var explosion=blast.animations.add('explosion'); blast.animations.play('explosion',10,false,true); ship.kill(); enemy.kill(); //music.stop(); this.scoreText.kill(); death_music.play("death_music"); game.time.events.remove(fireLoop); game.time.events.add(Phaser.Timer.SECOND * 2, function() { fianlScore = this.game.add.text(this.game.world.centerX,this.game.world.centerY, 'KILL: '+score, { fontSize: '32px', fill: 'yellow' }); fianlScore.anchor.setTo(0.5); gameOverText = this.game.add.text(this.game.world.centerX,this.game.world.centerY - fianlScore.height, 'GAME OVER', { fontSize: '32px', fill: 'red' }); gameOverText.anchor.setTo(0.5); //restart button restart=this.game.add.sprite(this.game.world.centerX,this.game.world.centerY + fianlScore.height+10,'restart'); restart.anchor.setTo(0.5); restart.scale.setTo(0.05,0.05); restart.inputEnabled = true; restart.events.onInputDown.add(restartGame, this); game.time.events.stop(); }, this); } //runs when ship collide power1 function s_power1_collide(ship,power){ power.kill(); game.time.events.remove(fireLoop); fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/10, fireBullet, this); game.time.events.add(Phaser.Timer.SECOND * 10, function(){ game.time.events.remove(fireLoop); fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/buttetSpwanSpeed, fireBullet, this); },this); } function changeEnemySpeed() { if(enemySpeed<=900) { enemySpeed+=5; } if(enemySpwanSpeed<=3) { enemySpwanSpeed+=0.025; } enemyLoop.delay=Phaser.Timer.SECOND*1/enemySpwanSpeed; } //send power up function powerFun() { x1=game.rnd.integerInRange(0,this.game.world.width); x2=game.rnd.integerInRange(0,this.game.world.width); power=this.game.add.sprite(x1,10,'power1'); power.anchor.setTo(0.5); var shine=power.animations.add('shine'); power.animations.play('shine',5,true,true); power.checkWorldBounds = true; power.outOfBoundsKill = true; powers.add(power); game.physics.arcade.enable(power); power.body.collisonWorldBounds=true; game.physics.arcade.moveToXY(power, x2, this.game.world.height+power.height, 400,0); powerDelay=game.rnd.integerInRange(20,35); powerUp.delay=Phaser.Timer.SECOND*powerDelay; } function restartGame(){ setStart(); game.time.events.start(); game.state.start("PreGameState"); } game.state.add("GameState",GameState); game.state.add("BootState",BootState); game.state.add("LoadingState",LoadingState); game.state.add("PreGameState",PreGameState); game.state.start("BootState"); main.js
  16. Hello everyone, i am having a hard time implementing the physics for a race like game where you can drive over "boosting" and "slowing" zones. The player can control in which lane the vehicle drives (left, mid, right). On the track there are different zones/areas. Boosting Zones should accelerate the vehicle and "Slowing" zones should really punish the player with very slow speed and a massive drag. The game is played in portrait mode with the vehicle going up. The camera is fixed on the vehicle. The lane switching is working and right now I am using tweens for that. My problem is the "natural" feeling for the acceleration / deceleration. I tried tweening the amount of pixels the y coordinate gets manipulated, I tried working with acceleration and velocity. Nothing of that "feels" right. The Zones fire events when ever the vehicle enters and leaves them. I am stuck at the physics part. What should I manipulate? Acceleration? Velocity? Drag? Friction? Inside my State: /** * handle Vehicle entering a zone! * * @param obstacle */ handleVehicleZoneEnter(event) { if (event.zone instanceof SlowingZone) { this.vehicle.speedEffect = 'SLOWED'; } if (event.zone instanceof BoostingZone) { this.vehicle.speedEffect = 'BOOSTED'; } } /** * handle vehicle zone leave * @param event */ handleVehicleZoneLeave(event) { if (event.zone instanceof SlowingZone) { this.vehicle.speedEffect = 'NONE'; } if (event.zone instanceof BoostingZone) { this.vehicle.speedEffect = 'NONE'; } } Inside my vehicle Object: // This gets called on every frame as long as the vehicle hasnt reached the end of the track adjustSpeed() { let minSpeed = 30; let normalSpeed = 500; let maxSpeed = 3000; switch (this.speedEffect) { case 'SLOWED' : this.body.drag.y = 500; this.body.friction.y = 500; break; case 'BOOSTED' : this.body.acceleration.y = -500; break; default : this.body.drag.y = 100; this.body.friction.y = 100; break; } } Thanks.
  17. Phaser Game Lag In Mobile

    Hi, I am new to phaser as well as game designing. I created my first game as hobby using phaser. it is working fine in desktop but lags very bad on mobile devices. Images I am using for game is very small. game is smaller that 2mb. I am attaching my main.js file hope someone can help me. thanks var buttetSpwanSpeed; var bulletSpeed; var enemySpwanSpeed; var enemySpeed; var golis; var enemies; var enemyLoop; var scoreText; var powers; var bulletSize; setStart(); //game phaser var game=new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.CANVAS,"gamearea"); var BootState={ //loding accets preload: function(){ this.load.image('LodingScreen', 'assets/desimulga.png'); this.load.image('background', 'assets/blue.png'); }, create: function(){ game.state.start("LoadingState"); }, }; var LoadingState={ //loding acc preload: function(){ bg=this.game.add.tileSprite(0,0,600,300,'background'); bg.height = game.height; bg.width = game.width; LodingScreen=this.game.add.sprite(this.game.world.centerX,this.game.world.centerY,'LodingScreen'); LodingScreen.anchor.setTo(0.5); LodingScreen.scale.setTo(0.5,0.5); this.load.image('spaceship', 'assets/player.png'); this.load.image('goli', 'assets/bullet.png'); //load ememies this.load.image('enemy1', 'assets/enemies/enemy1.png'); this.load.image('enemy2', 'assets/enemies/enemy2.png'); this.load.image('enemy3', 'assets/enemies/enemy3.png'); this.load.image('enemy4', 'assets/enemies/enemy4.png'); this.load.image('enemy5', 'assets/enemies/enemy5.png'); this.load.spritesheet('power1', 'assets/power/bulletUp.png',34,33,4); this.load.image('restart', 'assets/restart.png'); this.load.spritesheet('blast', 'assets/explosion.png',400,400,8); game.load.audio('fire', 'assets/music/bullet.mp3'); game.load.audio('killed', 'assets/music/killed.mp3'); //game.load.audio('bg_music', 'assets/music/background.mp3'); game.load.audio('death_music', 'assets/music/death.mp3'); game.load.audio('start_music', 'assets/music/start.mp3'); }, create: function(){ game.time.events.add(Phaser.Timer.SECOND * 2, function(){ bg.kill(); LodingScreen.kill(); game.state.start("PreGameState"); },this); }, }; var PreGameState={ //loding accets create: function(){ game.scale.refresh(); bg=this.game.add.tileSprite(0,0,600,300,'background'); bg.height = game.height; bg.width = game.width; Startb=this.game.add.text(this.game.world.centerX,this.game.world.centerY, 'TAP TO START' , { fontSize: '32px', fill: 'yellow' }); Startb.anchor.setTo(0.5); Startb.scale.setTo(0.5,0.5); ship=this.game.add.sprite(this.game.world.centerX,this.game.world.height*0.4,'spaceship'); ship.scale.setTo(0.4); ship.anchor.setTo(0.5); game.physics.arcade.enable(ship); bg.inputEnabled=true; start_music = game.add.audio('start_music'); start_music.allowMultiple = true; start_music.addMarker('start_music', 0, 30); bg.events.onInputDown.add(function(){ bg.inputEnabled=false; Startb.kill(); start_music.play("start_music"); // game.physics.arcade.moveToXY(ship, this.game.world.centerX, this.game.world.height*0.8, 300, 3000); // game.add.tween(ship).to( { y: game.world.height*0.8 }, 3000, Phaser.Easing.Sinusoidal.InOut, true); var tween = game.add.tween(ship).to({ x: [this.game.world.centerX, this.game.world.width*0, this.game.world.width, this.game.world.centerX], y: [this.game.world.height*0.4, this.game.world.height*0.5, this.game.world.height*0.6, this.game.world.height*0.8], }, 2000,Phaser.Easing.Quadratic.Out, true).interpolation(function(v, k){ return Phaser.Math.bezierInterpolation(v, k); }); game.time.events.add(Phaser.Timer.SECOND * 2, function() { bg.kill(); ship.kill(); game.state.start("GameState"); } ,this); }, this); }, }; var GameState={ //loding accets preload: function(){ }, create: function(){ //background this.background=this.game.add.tileSprite(0,0,600,300,'background'); this.background.height = game.height; this.background.width = game.width; this.background.inputEnabled=true; this.background.input.enableDrag(true); this.background.input.startDrag = function(pointer) { pointer.shipStart = new Phaser.Point(GameState.ship.x, GameState.ship.y); Phaser.InputHandler.prototype.startDrag.call(this, pointer); }; this.background.input.updateDrag = function(pointer) { GameState.ship.x = pointer.shipStart.x - pointer.positionDown.x + pointer.x; GameState.ship.y = pointer.shipStart.y - pointer.positionDown.y + pointer.y; GameState.background.x=0; GameState.background.y=0; }; //ship this.ship=this.game.add.sprite(this.game.world.centerX,this.game.world.height*0.8,'spaceship'); this.ship.scale.setTo(0.4); this.ship.anchor.setTo(0.5); game.physics.arcade.enable(this.ship); // this.ship.inputEnabled=true; // this.ship.input.enableDrag(true); //score this.scoreText = this.game.add.text(16, 16, 'Kills: 0', { fontSize: '32px', fill: '#fff' }); //background Music // music = game.add.audio('bg_music'); //music.play('', 0, 1, true); //bullet sound bullet_sound = game.add.audio('fire'); bullet_sound.allowMultiple = true; bullet_sound.volume=0.5; bullet_sound.addMarker('fire', 0, 0.5); //Killed sound killed_sound = game.add.audio('killed'); killed_sound.allowMultiple = true; killed_sound.addMarker('killed', 0, 0.5); //death music death_music = game.add.audio('death_music'); death_music.allowMultiple = true; death_music.addMarker('death_music', 0, 10); //groups of bullets and enemies golis=game.add.group(); enemies=game.add.group(); powers=game.add.group(); //fire bullet loop fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/buttetSpwanSpeed, fireBullet, this); //this.game.input.onTap.add(fireBullet, this); //create ememy loop enemyLoop=game.time.events.loop(Phaser.Timer.SECOND*1/enemySpwanSpeed, createEnemy, this); //change ememy speed and enemy spwan speed loop enemySpeedLoop=game.time.events.loop(Phaser.Timer.SECOND*1.5, changeEnemySpeed, this); //give powerup powerUp=game.time.events.loop(Phaser.Timer.SECOND*20, powerFun, this); }, update: function(){ //scrolling background this.background.tilePosition.y+=2; //keybord control if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { this.ship.y-=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { this.ship.y+=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { this.ship.x+=2; } if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { this.ship.x-=2; } //dont go out if(this.ship.y<0+this.ship.height/2) { this.ship.y=0+this.ship.height/2; } if(this.ship.y>this.game.world.height-this.ship.height/2) { this.ship.y=this.game.world.height-this.ship.height/2; } if(this.ship.x<0+this.ship.width/2) { this.ship.x=0+this.ship.width/2; } if(this.ship.x>this.game.world.width-this.ship.width/2) { this.ship.x=this.game.world.width-this.ship.width/2; } //check for collisions game.physics.arcade.overlap(golis,enemies,b_e_collide,null,this); game.physics.arcade.overlap(this.ship,enemies,s_e_collide,null,this); game.physics.arcade.overlap(this.ship,powers,s_power1_collide,null,this); }, }; //setting start game conditions function setStart(){ buttetSpwanSpeed=2; bulletSpeed=2000; enemySpwanSpeed=1; enemySpeed=300; score=0; bulletSize=1.2 } //fire bullet function function fireBullet(){ goli=this.game.add.sprite(this.ship.x,this.ship.y-this.ship.height/2,'goli'); goli.anchor.setTo(0.5); goli.scale.setTo(bulletSize,1); goli.checkWorldBounds = true; goli.outOfBoundsKill = true; //adding to group golis.add(goli); game.world.moveDown(goli); game.physics.arcade.enable(goli); goli.body.collisonWorldBounds=true; goli.body.velocity.y=-bulletSpeed; bullet_sound.play("fire"); } //create enemy function function createEnemy(){ enemyNo=game.rnd.integerInRange(1, 5); x1=game.rnd.integerInRange(0,this.game.world.width); x2=game.rnd.integerInRange(0,this.game.world.width); enemy=this.game.add.sprite(x1,10,'enemy'+enemyNo); enemy.anchor.setTo(0.5); enemy.scale.setTo(0.4); enemy.checkWorldBounds = true; enemies.add(enemy); enemy.outOfBoundsKill = true; game.physics.arcade.enable(enemy); enemy.body.collisonWorldBounds=true; enemy.angle=90; enemy.no=enemyNo; //moving enemy angleRedian=game.physics.arcade.moveToXY(enemy, x2, this.game.world.height+enemy.height, enemySpeed,0); angleDegree=angleRedian*57.2958; enemy.angle=90+angleDegree; } //runs when bullet collide to enemy function b_e_collide(goli,enemy){ //blast blast=this.game.add.sprite(enemy.x,enemy.y,'blast'); blast.anchor.setTo(0.5); blast.scale.setTo(0.5); var explosion=blast.animations.add('explosion'); blast.animations.play('explosion',30,false,true); //killing goli.kill(); enemy.kill(); //update scores if(enemy.no<4) { score+=1; killed_sound.play('killed'); } this.scoreText.text = 'Kills: ' + score; } //runs when ship collide to enemy function s_e_collide(ship,enemy){ blast=this.game.add.sprite(enemy.x,enemy.y,'blast'); blast.anchor.setTo(0.5); blast.scale.setTo(0.5); var explosion=blast.animations.add('explosion'); blast.animations.play('explosion',10,false,true); ship.kill(); enemy.kill(); //music.stop(); this.scoreText.kill(); death_music.play("death_music"); game.time.events.remove(fireLoop); game.time.events.add(Phaser.Timer.SECOND * 2, function() { fianlScore = this.game.add.text(this.game.world.centerX,this.game.world.centerY, 'KILL: '+score, { fontSize: '32px', fill: 'yellow' }); fianlScore.anchor.setTo(0.5); gameOverText = this.game.add.text(this.game.world.centerX,this.game.world.centerY - fianlScore.height, 'GAME OVER', { fontSize: '32px', fill: 'red' }); gameOverText.anchor.setTo(0.5); //restart button restart=this.game.add.sprite(this.game.world.centerX,this.game.world.centerY + fianlScore.height+10,'restart'); restart.anchor.setTo(0.5); restart.scale.setTo(0.05,0.05); restart.inputEnabled = true; restart.events.onInputDown.add(restartGame, this); game.time.events.stop(); }, this); } //runs when ship collide power1 function s_power1_collide(ship,power){ power.kill(); game.time.events.remove(fireLoop); fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/10, fireBullet, this); game.time.events.add(Phaser.Timer.SECOND * 10, function(){ game.time.events.remove(fireLoop); fireLoop=game.time.events.loop(Phaser.Timer.SECOND*1/buttetSpwanSpeed, fireBullet, this); },this); } function changeEnemySpeed() { if(enemySpeed<=900) { enemySpeed+=5; } if(enemySpwanSpeed<=3) { enemySpwanSpeed+=0.025; } enemyLoop.delay=Phaser.Timer.SECOND*1/enemySpwanSpeed; } //send power up function powerFun() { x1=game.rnd.integerInRange(0,this.game.world.width); x2=game.rnd.integerInRange(0,this.game.world.width); power=this.game.add.sprite(x1,10,'power1'); power.anchor.setTo(0.5); var shine=power.animations.add('shine'); power.animations.play('shine',5,true,true); power.checkWorldBounds = true; power.outOfBoundsKill = true; powers.add(power); game.physics.arcade.enable(power); power.body.collisonWorldBounds=true; game.physics.arcade.moveToXY(power, x2, this.game.world.height+power.height, 400,0); powerDelay=game.rnd.integerInRange(20,35); powerUp.delay=Phaser.Timer.SECOND*powerDelay; } function restartGame(){ setStart(); game.time.events.start(); game.state.start("PreGameState"); } game.state.add("GameState",GameState); game.state.add("BootState",BootState); game.state.add("LoadingState",LoadingState); game.state.add("PreGameState",PreGameState); game.state.start("BootState"); main.js
  18. var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { game.load.image('fondo', 'imgs/sky.png'); game.load.image('plataforma', 'imgs/platform.png'); game.load.image('diamante', 'imgs/diamond.png'); game.load.spritesheet('personaje', 'imgs/dude.png', 32, 48); } function create() { var plataforma; var suelo; var personaje; var diamantes; var bandeja; game.add.sprite(0,0, 'fondo'); plataforma = game.add.sprite(0, 100, 'plataforma'); plataforma.width = 800; suelo = game.add.sprite(0, game.world.height - 5, 'plataforma'); suelo.width = 800; suelo.height = 5; bandeja = game.add.sprite(50, game.world.height - 100, 'plataforma'); bandeja.width = 150; personaje = game.add.sprite(32, 0, 'personaje'); } function update() { } When I open this, a message appears at the console: Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:///home/roger/Escritorio/PhaserJuego/imgs/sky.png may not be loaded. at s.WebGLRenderer.updateTexture (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:160952) at s.WebGLSpriteBatch.renderBatch (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:177239) at s.WebGLSpriteBatch.flush (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:177030) at s.WebGLSpriteBatch.render (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:172219) at i.Sprite.s.Sprite._renderWebGL (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:134036) at i.World.s.DisplayObjectContainer._renderWebGL (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:130384) at i.Stage.s.DisplayObjectContainer._renderWebGL (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:130384) at s.WebGLRenderer.renderDisplayObject (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:159001) at s.WebGLRenderer.render (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:158569) at i.Game.updateRender (file:///home/roger/Escritorio/PhaserJuego/phaser.min.js:3:287450) s.WebGLRenderer.updateTexture @ phaser.min.js:3 s.WebGLSpriteBatch.renderBatch @ phaser.min.js:3 s.WebGLSpriteBatch.flush @ phaser.min.js:3 s.WebGLSpriteBatch.render @ phaser.min.js:3 s.Sprite._renderWebGL @ phaser.min.js:3 s.DisplayObjectContainer._renderWebGL @ phaser.min.js:3 s.DisplayObjectContainer._renderWebGL @ phaser.min.js:3 s.WebGLRenderer.renderDisplayObject @ phaser.min.js:3 s.WebGLRenderer.render @ phaser.min.js:3 updateRender @ phaser.min.js:3 update @ phaser.min.js:3 updateRAF @ phaser.min.js:3 window.requestAnimationFrame.forceSetTimeOut._onLoop @ phaser.min.js:3 requestAnimationFrame (async) updateRAF @ phaser.min.js:3 window.requestAnimationFrame.forceSetTimeOut._onLoop @ phaser.min.js:3 requestAnimationFrame (async) updateRAF @ phaser.min.js:3 window.requestAnimationFrame.forceSetTimeOut._onLoop @ phaser.min.js:3 requestAnimationFrame (async) start @ phaser.min.js:3 boot @ phaser.min.js:3 i.Device._readyCheck @ phaser.min.js:3 What does it mean? PD:Index.html is OK, and the images too. Thanks.
  19. I am making a rpg that will have skills with complex movement like if I use my A skill my player will jump and then dash diagonally back to the ground. My problem is not knowing how to achieve this. I tried with making it move to the sky first and then coming back down but they combine and make him only move diagonally. My guess is using timers for it but I don't know where to start. Any help would be appreciates, even if it's not code, just a step by step on how can I accomplish this, I can figure something out later.
  20. I'am looking for experienced Phaser coder for minimum of 2 upcoming mobile game projects, and finish one that's half done. Its crucial that applicants are able to add interesting mechanisms to the games, very good understanding of making games for phones, to keep the performance of the games, make sure resolution is scaling properly, short loading times and so on... Being able to work on flexible systems and even add your own touch to the game. You should know that these projects, even tho majority of them will be small, might take even couple months to finish. Pay is per project, unless objected and explained why it should be different. Half upfront half at the end of each game developed. It is important for you to please send your applications to this email address: pivovarnik@outlook.com , and mention where have you found me on. Within the applications, include your portfolio of previous games you've worked on, and how long you've been working with Phaser. Also whats the longest project or series of projects you've been hired for, or worked at yourself and finished. EDIT: I FOUND A CODER, THANK YOU ALL FOR INTEREST.
  21. Basically that's what I want to achieve, removing/hiding a part of a sprite/image/graphic. That's the opposite of how masks work in Phaser, so does anyone know how to achieve that result?
  22. Hey there! I'm a little confused about the soundManager and how to properly handle the playback of sounds. What I want to do is have a master volume for music and a master volume for sfx. When fading music in and out it always goes to a volume of 1 so it does not seem to be a good idea to handle the sound volumes individually for each sound or music track. Would I set up 2 different sound managers and add all sounds in there and then control the Soundmanagers volume? I can't seem to find proper examples or tutorials on that.. Any pointers would be greatly appreciated! Thanks Zampano
  23. Phaser in combination with arrays

    Hello everyone, I've been working on a game inspired by Heroes of Might and Magic and Final Fantasy-esque and I wanted to turn it into a browser game. Everything's been going well until I hit a bump in the road. I thought it would have been smart and easier to put all the sprites of the creatures in an array but doing so only let me use one sprite at a time so if the fight was between 4 Halberdiers and 4 Skeletons then they would on both sides only have 1 sprite. The stats for all the creatures are in a database and so far worked fine. var chosensprite =[]; chosensprite[1]=game.add.sprite(-100 ,-100 , 'skeleton'); chosensprite[2]=game.add.sprite(-100 ,-100 , 'halberdier'); This is what I used as an array. I tried to hardcode all the characters but doing so only created more of a clustermess which doesn't seem good to work with. // The playerunit1 and its settings playerunit1 = game.add.sprite(32+32, game.world.height/numcreaturesplayer*0+64, 'halberdier'); playerunit1.kill(); playerunit2 = game.add.sprite(32+32, game.world.height/numcreaturesplayer*1+64, 'halberdier'); playerunit2.kill(); playerunit3 = game.add.sprite(32+32, game.world.height/numcreaturesplayer*2+64, 'halberdier'); playerunit3.kill(); playerunit4 = game.add.sprite(32+32, game.world.height/numcreaturesplayer*3+64, 'halberdier'); playerunit4.kill(); enemyunit1 = game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*0+64, 'skeleton'); enemyunit1.kill(); enemyunit2 = game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*1+64, 'skeleton'); enemyunit2.kill(); enemyunit3 = game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*2+64, 'skeleton'); enemyunit3.kill(); enemyunit4 = game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*3+64, 'skeleton'); enemyunit4.kill(); selector = game.add.sprite(0,0, 'mselector'); /* playerunit1bolt = game.add.image(playerunit1.x+800, playerunit1.y+16, 'star'); enemyunit1bolt = game.add.image(enemyunit1.x+800, enemyunit1.y+86, 'star'); */ for (var i=0;creaturestats[i];) { playerunit1.unittype= 2; if (playerunit1.unittype == creaturestats[i]['unittype']) { if (playerunit1.unittype = 2){ playerunit1 = game.add.sprite(32+32, game.world.height/numcreaturesplayer*0+64, 'halberdier'); } //playerunit1 = chosensprite[playerunit1.unittype];playerunit1.x=64;playerunit1.y=64; playerunit1.damage=creaturestats[i]['damage']; playerunit1.healthblock=creaturestats[i]['healthblock']; playerunit1.units=creaturestats[i]['unitamount']; playerunit1.defense=creaturestats[i]['defense']; playerunit1.damagetype=creaturestats[i]['damagetype']; playerunit1.attacktype=creaturestats[i]['attacktype']; } playerunit2.unittype= 1; if (playerunit2.unittype == creaturestats[i]['unittype']) { if (playerunit2.unittype = 1){ game.add.sprite(32+32, game.world.height/numcreaturesplayer*1+64, 'skeleton'); } //playerunit2 = chosensprite[playerunit2.unittype];playerunit2.x=128;playerunit2.y=128; playerunit2.damage=creaturestats[i]['damage']; playerunit2.healthblock=creaturestats[i]['healthblock']; playerunit2.units=creaturestats[i]['unitamount']; playerunit2.defense=creaturestats[i]['defense']; playerunit2.damagetype=creaturestats[i]['damagetype']; playerunit2.attacktype=creaturestats[i]['attacktype']; } playerunit3.unittype= 1; if (playerunit3.unittype == creaturestats[i]['unittype']) { if (playerunit3.unittype = 1){ game.add.sprite(32+32, game.world.height/numcreaturesplayer*2+64, 'skeleton'); } //playerunit3 = chosensprite[playerunit3.unittype];playerunit3.x=500;playerunit3.y=200; playerunit3.damage=creaturestats[i]['damage']; playerunit3.healthblock=creaturestats[i]['healthblock']; playerunit3.units=creaturestats[i]['unitamount']; playerunit3.defense=creaturestats[i]['defense']; playerunit3.damagetype=creaturestats[i]['damagetype']; playerunit3.attacktype=creaturestats[i]['attacktype']; } playerunit4.unittype= 2; if (playerunit4.unittype == creaturestats[i]['unittype']) { if (playerunit4.unittype = 2){ game.add.sprite(32+32, game.world.height/numcreaturesplayer*3+64, 'halberdier'); } //playerunit4 = chosensprite[playerunit4.unittype];playerunit4.x=300;playerunit4.y=20; playerunit4.damage=creaturestats[i]['damage']; playerunit4.healthblock=creaturestats[i]['healthblock']; playerunit4.units=creaturestats[i]['unitamount']; playerunit4.defense=creaturestats[i]['defense']; playerunit4.damagetype=creaturestats[i]['damagetype']; playerunit4.attacktype=creaturestats[i]['attacktype']; } enemyunit1.unittype= 2; if (enemyunit1.unittype == creaturestats[i]['unittype']) { if (enemyunit1.unittype = 2){ game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*0+64, 'halberdier'); } enemyunit1.damage=creaturestats[i]['damage']; enemyunit1.healthblock=creaturestats[i]['healthblock']; enemyunit1.units=creaturestats[i]['unitamount']; enemyunit1.defense=creaturestats[i]['defense']; enemyunit1.damagetype=creaturestats[i]['damagetype']; enemyunit1.attacktype=creaturestats[i]['attacktype']; } enemyunit2.unittype= 2; if (enemyunit2.unittype == creaturestats[i]['unittype']) { if (enemyunit2.unittype = 2){ game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*1+64, 'halberdier'); } enemyunit2.damage=creaturestats[i]['damage']; enemyunit2.healthblock=creaturestats[i]['healthblock']; enemyunit2.units=creaturestats[i]['unitamount']; enemyunit2.defense=creaturestats[i]['defense']; enemyunit2.damagetype=creaturestats[i]['damagetype']; enemyunit2.attacktype=creaturestats[i]['attacktype']; } enemyunit3.unittype= 2; if (enemyunit3.unittype == creaturestats[i]['unittype']) { if (enemyunit3.unittype = 2){ game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*2+64, 'halberdier'); } enemyunit3.damage=creaturestats[i]['damage']; enemyunit3.healthblock=creaturestats[i]['healthblock']; enemyunit3.units=creaturestats[i]['unitamount']; enemyunit3.defense=creaturestats[i]['defense']; enemyunit3.damagetype=creaturestats[i]['damagetype']; enemyunit3.attacktype=creaturestats[i]['attacktype']; } enemyunit4.unittype= 1; if (enemyunit4.unittype == creaturestats[i]['unittype']) { if (enemyunit4.unittype = 2){ game.add.sprite(game.world.width - 128-32, game.world.height/numcreaturesenemy*3+64, 'skeleton'); } enemyunit4.damage=creaturestats[i]['damage']; enemyunit4.healthblock=creaturestats[i]['healthblock']; enemyunit4.units=creaturestats[i]['unitamount']; enemyunit4.defense=creaturestats[i]['defense']; enemyunit4.damagetype=creaturestats[i]['damagetype']; enemyunit4.attacktype=creaturestats[i]['attacktype']; } i++; } So my question is if there is anyone well known with Phaser and could help me work out the solution with an array, another solution or if they're is no other choice but to hardcode it or work with HTML5 instead of Phaser. Thank you in advance! index.php
  24. Slashing.Io

    This is the first html5 and multiplayer game that I built for a personal project. http://www.slashing.io/ The server is not near good at the moment, so I'm optimizing it, but I still wanted to showcase my idea. Please, I appreciate any comment and feedbacks to improve the game.
  25. xxXDaRkXxx

    Hi everyone ! I'm glad to show you my first game created with phaser ! It was a pleasure to do it. xxXDaRkXxx is available here : https://vinkkk.itch.io/xxxdarkxxx