Search the Community

Showing results for tags 'es6'.



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

  1. Phaser/Cordova/Webpack(ES6)

    I created a quickstart application that I hope would be useful to some of you. It is a Phaser 2.8.8 quick start application that incorporates Webpack (ES6), and Cordova. It supports iOS and Android out of the box, along with all default Phaser supported web browsers. https://github.com/udia-software/phaser-cordova-es6 The code is on Github and is licensed under Apache V2. Enjoy!
  2. Are you using JavaScript ES 6?

    Hi, In Phaser Editor we are about to replace the current JavaScript intelli-sense engine by the one used by VSCode (Salsa). Salsa works well for JavaScript ES6 but for ES3 it lacks important features like type inference of prototype inheritance. But, is not the time to forget ES3 and start coding in ES6? If you want to target older browsers you can compile the ES6 code into ES3 just before to publish the game (as probably you are doing now to create the .min files), but in the meantime, you can code and test in ES6. ES6 is very nice for Phaser games development, especially when you want to create custom objects, like sprites, just compare these codes: ES6: class MySprite extends Phaser.Sprite { constructor(game) { super(game, "dude"); } update() { // custom behavior } } ES3: MySprite = function (game) { Phaser.Sprite.call(this, game, "dude"); } MySprite.prototype = Object.create(Phaser.Sprite.prototype); MySprite.prototype.constructor = MySprite; MySprite.prototyte.update = function () { // custom behavior } The ES6 code is way more clear and simple. Actually, the ES3 way is so confusing that probably I wrote it wrong ;-)
  3. Hello, How can I use Babylon's extensions with NPM imports (es6 style)? To resume my problem: 1. I use NPM and Webpack for my project. To use Babylon I've install the node module babylonjs and I import the lib with the line: import BABYLON from 'babylonjs' 2. I would like use too the Sky extension https://doc.babylonjs.com/extensions/sky To do that I try to import it with the line: import {skyMaterial} from 'babylonjs/dist/preview release/materialsLibrary/babylon.skyMaterial.min.js' 3. The compilation is done but in my Browser I've an error : Uncaught ReferenceError: __extends is not defined at eval (webpack-internal:///36:1) at BABYLON (webpack-internal:///36:1) at eval (webpack-internal:///36:1) at Object.<anonymous> (app.js:951) at __webpack_require__ (app.js:660) at fn (app.js:86) at eval (webpack-internal:///29:7) at Object.<anonymous> (app.js:904) at __webpack_require__ (app.js:660) at fn (app.js:86) I've forgot something or it's the wrong way?
  4. Hi. In v2 (community edition, as far as I've tested) you could, using webpack and the expose-loader plugin, pretty much use Phaser in a bundler environment and get full (except when a physics engine was selected, but it's not a big deal) intellisense/auto-complete in VSCode and in other editors too, I believe. You could code using ES6 and lint the whole thing without issues. It doesn't seem to be the same in v3. Importing (import Phaser from 'phaser';) doesn't seem to return the same result in v3 as it did in v2 - I can't have const game = new Phaser.game(options); - and the phaser3-project-template npm package shows a global import (import 'phaser';), which causes intellisense/linting to fail. Is there a way to have Phaser imported into a const instead of the global space and have it "work" the way it used to in v2? Is it done in a different way? I know things have changed in the core, but I was hoping to keep the same tooling as before, with intellisense and linting working. Thanks, and please forgive the broken English.
  5. Use panda with ES6

    Hi, How can I use panda with ES6? I mean, I downloaded the code (with get an index.html, engine and game dorectories) I have tested and in main.js works fine, but I want to import panda on another javascript file to get all core using the import, just import game from 'engine/core' But i get a small object, but doesn't get a full object, for example, I don't get the complete object My structure is this . └── demo ├── _demo │ ├── assets │ │ └── Images │ │ ├── frog.jpg │ │ └── logo.png │ └── settings.json ├── app.js ├── index.html ├── js │ └── pandajs │ ├── engine │ │ ├── analytics.js │ │ ├── audio.js │ │ ├── camera.js │ │ ├── core.js │ │ ├── debug.js │ │ ├── keyboard.js │ │ ├── loader.js │ │ ├── particle.js │ │ ├── physics.js │ │ ├── pixi.js │ │ ├── pool.js │ │ ├── renderer.js │ │ ├── scene.js │ │ ├── storage.js │ │ ├── system.js │ │ ├── timer.js │ │ └── tween.js │ └── game │ ├── config.js │ └── main.js ├── media │ └── logo.png ├── scss └── styles.scss This is my app.js file import game from './js/pandajs/engine/core'; game.module( 'game.main' ) .body(function() { game.addAsset('logo.png', 'logo'); game.createScene('Main', { backgroundColor: 0xb9bec7, init: function() { var logo = new game.Sprite('logo'); logo.anchor.x = 0.5; logo.anchor.y = 0.5; logo.position.x = game.system.width / 2; logo.position.y = game.system.height / 2; this.stage.addChild(logo); var tween = new game.Tween(logo.scale); tween.to({ x: 1.1, y: 1.1 }, 1000); tween.repeat(); tween.yoyo(); tween.start(); } }); }); And I want use the app.js to import panda and create my game with classes. Is it possible? I want to do it to because we need create many simple games, but I have tested pixi.js and really doesn't like me and I want to use panda but I must use it with ES6 Thanks
  6. Hi, Someone have tried to use LegacyPbrMaterial with webpack? I copied file babylon.legacyPbrMaterial.min.js and made import in project (import "babylonjs/babylon.legacyPbrMaterial") but after that I get error Uncaught ReferenceError: __extends is not defined at babylon.legacyPbrMaterial.js:1 at BABYLON (babylon.legacyPbrMaterial.js:1) at Object.exports.byteLength (babylon.legacyPbrMaterial.js:2) at __webpack_require__ (bootstrap 3ce2b0a…:19) I have same erro if i try ti use inpsector. I am missing some config for webpack or typescript?
  7. Hi, if I use import { Engine } from "babylonjs"; I get error that babylon.d.ts is not a model. Looks like that export = BABYLON is missing at the end of file. Could it be added or there is reason why it is missing? I saw this thread but looks like it still is missing in git
  8. Latest NPM for BabylonJS 3.0 alpha includes Canvas2D! I am having difficulty importing Canvas2D into my project. I have no troubles at all with regular BabylonJS only with importing Canvas2D. // I can import the main babylonJS in a variety of ways and they all work. // explicit imports import { Sound, Mesh, ShadowGenerator, ... } from 'babylonjs' // default and named import BABYLON, { Sound, Mesh, ShadowGenerator, ... } from 'babylonjs' // tried also named default only and * After that I am importing the Canvas2D and have tried various ways. // named default import import Canvas2D from 'babylonjs/babylon.canvas2d' // as side-effect import from 'babylonjs/babylon.canvas2d' // explicit imports import { ScreenSpaceCanvas2D } from 'babylonjs/babylon.canvas2d' The error I am getting is "TypeError: Cannot read property 'Effect' of undefined". So, basically line 1 of babylon.canvas2d, where BABYLON is undefined. Removing those will fail later (ie: BABYLON.Vector2 being undefined). I was reading on the ES6 spec that there is no guarantee of ordering only that the imports will all be run before code is executed. I looked through other NPMs where I can import add on modules separately and they have extra declarations in package.json (ie: "jsnext:main": "index", "module": index") and they are exporting explicitly in index.js the other modules from the main project. I tried that and a few other things, but am unable to get Canvas2D to import unfortunately. If anybody has successfully imported BabylonJS without creating their own bundle any tips would be appreciated. I'm using webpack and babel (https://babeljs.io/).
  9. Hi, Since the problem took me over a week to figure out, here is my solution to bundle your project using web-pack keeping Babylon as a dependency. NB: I am not certain what are the NECESSARY steps (ie what I could simplify) but those are SUFFICIENT steps. My constraints were : The final bundle can be imported both in the browser and in node using any kind of import method : require(), import/export, or <script src=...> tags It has to protect against errors in node due to access to window or document that will be undefined BABYLON has to load has a global in the browser using the script tag (window.BABYLON) BABYLON needs to include Canvas2D BABYLON needs to remain external of the bundle so the custom library is light and in theory could load any version of BABYLON Solution to protect loading in node.js: Build a custom bundle on Babylon website with Canvas2D ONLY, un-minified, and WITHOUT OIMO OR HANDJS. I did not test all possibilities but since the bundle is a concatenation suppose to be web compatible only, the exports will break in webpack or node in general. But using only this custom version will produce bugs in node due to access to undefined window. Then I had to bundle this custom build using webpack, you can see the configuration of webpack and the builder.js here : https://github.com/albertbuchard/experiment-babylon-js.git The important thing here is how the builder checks for window being defined and the webpack config exporting your named library with UMD. Publish this bundle to NPM (in the github look at the package.json it has three scripts to produce a unminified version, a minified version, and publish the repo on npm) Those two steps will allow to load Babylon using any kind of import method, and do not produce errors in node (but returns an empty object, of course any call to BABYLON function will fail) Solution to keep Babylon as a dependency in your custom library: In your library npm install the-custom-babylon-we-just-built Import BABYLON in your scripts any way you want using this custom repo ( es6 import syntax will work <3 ) i.e import BABYLON from 'the-custom-babylon-we-just-built' Then take a look at the webpack config and builder.js of this repo to understand how to manage EXTERNALS: https://github.com/albertbuchard/Experiment.js The key element here is how you write your external array: externals: { ... lodash: { commonjs: 'lodash', commonjs2: 'lodash', amd: 'lodash', root: '_', }, ... 'experiment-babylon-js': { commonjs: 'experiment-babylon-js', commonjs2: 'experiment-babylon-js', amd: 'experiment-babylon-js', root: 'BABYLON', }, ... 'experiment-babylon-js/lib/babylon.custom.js': { commonjs: 'experiment-babylon-js/lib/babylon.custom.js', commonjs2: 'experiment-babylon-js/lib/babylon.custom.js', amd: 'experiment-babylon-js/lib/babylon.custom.js', root: 'BABYLON', }, }, All but the root (Global environment reference) must be the NAME OF OUR MODULE as you would import it using require('NAME OF YOUR MODULE') so usually the name of your npm folder like the first two exaple, OR the direct path to the file you want to load like the third example. It has to be the same as the import names you are using in your library. So if you import babylon like so : // in your library const BABYLON = require('./path/to/babylon.js') // in your webpack config externals: { ... './path/to/babylon.js': { commonjs: './path/to/babylon.js', commonjs2: './path/to/babylon.js', amd: './path/to/babylon.js', root: 'BABYLON' } ... } Hope it will help some of you ! @Nikos123
  10. Extends class from different folder

    I'm using https://github.com/lean/phaser-es6-webpack for our company projects. Currently, we separate code into different projects, a framework and games using it. But when we trying to extends class from our framework using relative path, ex: import Sprite from "../../Framework/src/Sprite" class GameSprite extends from Sprite we get this error: Uncaught TypeError: Class constructor cannot be invoked without 'new'
  11. Hello guys I have recently started doing my projects in ES6 and I am wondering the following. //Player.js class Player extends Phaser.Image { constructor(game, x, y, sheet, key) { super(game, x, y, sheet, key); } } export default Player; //GameState.js import Player from 'views/Player'; class GameState extends Phaser.State { create() { this.player = new Player(); // Cannot see required parameters //If I call it like that this.player = Player.constructor() // I can see them - obviously } } export default GameState; Should I just initialize the new Player and then just call the constructor so I can actually create what I need?
  12. Hello fellow devs I have used THIS template to create my own project. It all works well, but I am working with WebStorm and I am struggling to create a debug profile. I don't want to use the Google Chrome debug. Any ideas? P.S. I also read something about live mobile debug - is that straight on a device? If so - what kind of setup do I need to make such connection between my IDE and the device? Is it also possible to live-reload only the changes that have been made and not the whole game state?
  13. I've been working on a BabylonJS game for fun and wanted to try out integrating with React and Redux for maintaining game state and showing a UI outside of the canvas. I took as a starting point the Quarto game from Temechon (with permission). I changed the game a bit mostly so that there was enough state from my Redux reducer to do the full UI in React, so remove all direct DOM manipulation and moved logic around for that (some using 'redux-saga'). There is an npm which contains the React <Scene .../> component and a redux middleware for intercepting actions. In the demo, you can see when you mouse off the canvas that the lighting is dimmed - this is not part of the component, but a prop called from the event added in Quarto. There is built-in support for showing the debug-layer via a React component <Button onClick={this.toggleDebug}>...</Button>. The full demo can be viewed here (click on Quarto link). Note that the game is loaded as a fractal and only downloaded when you click the link - good for Single Page Applications with multiple components. https://brianzinn.github.io/react-redux-babylonjs-starter-kit/ Original demo (includes a tutorial to explain the game): http://www.pixelcodr.com/games/quarto/index.html The source code for the NPM component is: https://www.npmjs.com/package/react-babylonjs https://github.com/brianzinn/react-babylonJS/ Full source-code of the demo is in a starter kit I created (forked from davezuko) that uses react-babylonjs with hot reloading and ES6 support (via babel) and to have your babylonJS project running without needing apache or IIS. So, this is a quick way to get started. There are issues for sure, but my workflow is going well and that is my main goal - speed of development. Make a change see it right away. https://github.com/brianzinn/react-redux-babylonjs-starter-kit Things I would like to add are support for more events, add tutorial in Quarto, figure out why multiple events fire sometimes, WebGL crash issues, etc - so not a v1 component, but worthwhile to share I think. If you are looking for deploying across mobile platforms then you may want to look at other GUI options, but especially for rapid prototyping or targeting desktop browsers this was really fast for me, especially with HMR.
  14. I am writing games in Phaser using webpack for building deployment versions and running hot reload server for development and i am using karma for testing. I am new to most of those technologies so i am open to critique but if someone looks for starting point for connecting Phaser with those technologies i have made git repo that maybe is good starting point to start building your own projects: https://github.com/Xesenix/game-webpack-react-phaser-scaffold If you are more advanced at using such an environment for developing phaser games I would appreciate advices what i can fix with it
  15. Hey people; I have been developing a framework. I want to publish it as an npm package. I bundle my code with webpack on framework project and I am using bundled js file inside the game project which is bundled via browserify. I wanted to test it with different bundlers. My case is; On framework; the folder hieararchy is; -src --index.js -release --index.js Webpack bundles ./src/index.js to ./release/indes.js in ./src/index.js I have simplest code snippet as follows; module.exports = 'tattaratatta'; on game project that I use framework, I have app.js and bundle.js. on app.js inside the game project I have the following code; var fr = require('./../framework/release/index.js'); console.log(fr); this logs out an empty object. but when I change it to; var fr = require('./../framework/src/index.js'); console.log(fr); it logs out tattaratatta correctly. I watched some tutorials on youtube, read some tutorials online but can't find out what I am doing wrong. Appearently, I can't seem to require te module from the bundled file. Any idea?
  16. Hello! I just started playing around with Phaser today and I'm enjoying it a lot. I come from a frontend / UI engineering background so I'm used to modularizing my components and tying them together using require statements. So far, all the examples I've seen in Phaser are all written in a single file which makes me uncomfortable if my game is to become more complicated. For example I have a group called "ships" which can all shoot "weapons" I want each ship to have properties like current ammo, health, player_id, etc. However I've only been able to define them this way. ships = game.add.physicsGroup(); // ships.enableBody = true /* SET UP PLAYER */ player = ships.create(0, 0, 'ship'); player.anchor.setTo(0.5, 0.5); game.physics.arcade.enable(player); /* SET UP LASER */ laser = game.add.weapon(30, 'bullet'); // fire 30 shots every 100ms laser.bulletKillType = Phaser.Weapon.KILL_DISTANCE; laser.bulletKillDistance = 500; laser.bulletRotateToVelocity = true; laser.bulletSpeed = 600; laser.fireRate = 100; laser.trackSprite(player, 0, 0, true); Now I would ideally like to have something like this: class Ship { constructor(x, y){ ships.create(x, y,'ship'); ... health = 500; armor = 600; ammoCapacity = 1000; currentAmmo = 1000; } } But currently I have to declare a ton of global variables. I found the phaser-es6-boilerplate. Is this is the standard and should I be safe following the paradigms expressed there? Thanks for any feedback!
  17. Phaser Arcade Slopes ES6 help

    I've been trying to get a ES6 version of a game together. I've had to shim Phaser (to get around a PIXI is undefined issue). 'use strict'; require('./../../dist/pixi'); require('./../../dist/phaser'); require('./../../dist/phaser-arcade-slopes'); module.exports = Phaser; I've wanted to incorporate a plugin (phaser-arcade-slopes), so I attach it to Phaser in the Shim (see above). There seems to be an issue when I start to use it. I get: SAT is undefined This is a library phaser-arcade-slopes relies on. Here is my code. https://github.com/richardhealy/emagine Should be pretty easy to setup. nom install npm run build-init nom build If you go to index.html, you'll see the error in the console.
  18. Is there any comprehensive es6 boilerplate for Babylon? For Phaser is a lot, but for Babylon I haven't found yet. If somebody has done some kind of boilerplate, could I get it also?
  19. Debug Phaser ES6 + WebPack in WebStorm

    Hey guys, I have decided to start using webpack and ES6 with my games, I have managed to run a sample with 'npm start', however I am unable to debug it in WebStorm. I am using the example here: https://github.com/SvetoslavKuzmanov/phaser-game-boilerplate This is my debug configuration in the image. I would like to use npm directly from WebStorm and be able to debug my code with preview in the browser. Also I have heard that it is possible to have live editing set up, so my code changes will appear immediately in the browser. Has anyone done that?
  20. Phaser ES6

    Hi Guys, I have been using ES6 for my game development and I really enjoy the functionality it supports. I started of using this example (Boilerplate) and kept the gulp compiling/traversing script, as it suits my needs well. I ran into a little challenge, that I could not figure out yet, but maybe somebody else has a good idea on how to achieve the following: After the gulp script ran through it creates a build.js file, which starts like this (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 'use strict'; and ends like this: },{}]},{},[44]) So it creates this nice little sandbox around my code. The sandbox is unfortunately also what is giving me a little headache, as I would like to consume some off the classes/methods outside of sandbox. For instance to simple call new Game(); from another script, that is linked to my index file. Important to mention here is that I would like to keep the sandbox and only expose certain functionality to the outside world. Hope somebody has a clever idea to help me on this issue! Thanks guys!
  21. Endless runner - object pool

    Hello there. For my first Phaser game I want to create an endless runner. I want to be sure right from the start that everything I'm doing is done in the best possible way. I know there might be no straight / easy solutions, but I want to know your opinion, as my experience with Phaser is rather short (1 week). 1. Idea I'm having one big Phaser.Group called Platforms, which is called right in the main game and that group handles everything when it comes to the groups. Inside of Platforms you can spawn platform which is also a group. And that group (platform) has many instances of Ground, which is extension of the Phaser.Sprite // ground.js class Ground extends Phaser.Sprite { constructor(game, x, y, frame) { super(game, x, y, 'tileset', frame); const BODY_OFFSET = 3; this.game.physics.arcade.enable(this); this.anchor.setTo(0, 1); this.body.immovable = true; this.body.allowGravity = false; this.body.offset.y = BODY_OFFSET; this.body.height -= BODY_OFFSET; this.body.velocity.x = -this.game.global.speed; this.body.friction.x = 0; } } export default Ground; // platform.js import Ground from './ground'; class Platform extends Phaser.Group { constructor(game, { startX = 0, startY = game.height, width = game.width } = {}) { super(game, startX); this.settings = { startX, startY, width }; this.flags = { extended: false }; // Platform building loop // 1. Prepare variables let tileLevel = 1, tileFrame = 8; // Y axis for(let y = startY; y <= this.game.height + this.game.global.tileSize; y += this.game.global.tileSize) { // X axis tileLevel === 1 ? tileFrame = 8 : tileFrame = 1; for(let x = 0; x < width; x += this.game.global.tileSize ) { this.add(new Ground(this.game, x, y, tileFrame)); } tileLevel++; } } update() { // When off bounds - spawn another platform if ((this.centerX < this.game.width) && (!this.flags.extended)) { this.flags.extended = true; this.game.global.spawnPlatform.dispatch(this.right); } if(this.right < 0) { this.destroy(); } } } export default Platform; Every little piece of ground has the same velocity and settings. Player collision is checked based on platforms.children. For now I'm destroying platform when it goes off screen and calling global spawnPlatform function when middle of a platform is on the left border of the screen (to spawn it a little earlier). And here come my questions and ideas: 2. Ideas & questions Recently I've learned about Object pools. My platforms were done by doing some random numbers (width, height etc) but I've noticed that even with one platform performance goes dramatically down. I mean maybe not dramatically, but it's not a good sign. There was that "sawtooth" pattern on the memory section (DevTools). Here are my ideas: 2.1 Leave it as it is Platform spawns, platform goes off the screen, platform gets destroyed. 2.2 Generate many random platforms at the beginning, and then just re-use them At the beginning game would generate a big array of defined platforms, that would still be much-less random. When the platform goes off the screen it's not destroyed. Instead it's killed. But here comes my problem - you can't kill groups. Only sprites inside (Ground instances) could've been killed. But will it be really a better solution? Killing every ground, moving the platform out of 'living' array, and then when platform gets spawned revive them? 2.3 Generate object pool of Ground instances and use them as 'blocks' for platforms I think that's pretty much the same as 2.2, but maybe a little bit different. Creating big arrays of different types of blocks, and then using them to build platforms. I think like max 5 platforms will be visible at one moment on the screen so I wouldn't have to create many blocks. Platform goes off - Ground(s) get killed, group destroyed (?) Also before I end - on the screenshot you can see that sometimes the connections between tiles are visible. I don't think that's the spritesheet case. Maybe something with small delays between creating each platform? Not quite sure. Any ideas? Another problem lies in gaps between each platform. I guess that's caused by a delay between creating a platform and spawning it. I want to ensure I'm doing everything right from the beginning, so pardon me if I sound stupid or that's just silly question. Hopefully someone will be able to answer my question and help me out. Thanks for creating Phaser. Making games have always been my dream, but recently I was focused on the front-end development. Now I can combine those two
  22. Empty Phaser ES6 template?

    Has anyone done or found blank ES6 Phaser template? All I have found, are just ready multiple state and gulp templates. ES6 is new thing for me, so that's why I'd wish to get just blank project template without multiple states etc.
  23. Hello everyone! I have kind of a complicated question. I'm currently doing my thesis at uni, the topic being web based games (specifically 3d ones). I'm going to create a small multiplayer Bomberman clone and reflect the process on the thesis itself; what problems I had, how does the development compare to for example Unity etc. I have used Unity kind of a lot and know the basics of threejs. However, after many hours I decided to make the game with Babylon, since it seems to be more suitable for the task at hand. I have a strong web-development background, so the thesis pretty much gives me some time to learn more about game programming Ah yes the question itself, which is pretty much about setting up the project. I would like to have help with these areas: Using modern JavaScript, ES6 syntax and features for BabylonJS. Maybe load the modules using, for example, SystemJS. Is this a silly idea? Is it best to use, for example, Gulp for the deployment stuff, like minification? However, I have not found that many sample projects at all for the engine itself. Maybe I haven't digged far enough? If anyone has any useful links, sample projects or ideas to share with me I would be really blessed. Thank you in advance for reading my lengthy post
  24. Phaser ES6

    Phaser Game with ES6 Phaser object orientation with objects and class. We do not use prototype See one example class file class Items extends Phaser.Sprite { constructor(game,sprite) { var arrEnemyX = [500,1500,1800,1300,1400,1900,2200,2500,1701,2250]; var arrEnemyY = [1200,1400,2000,2100,1000,1250,1650,1450,2101,2021]; var vx = Math.floor((Math.random()*10)+0); var vy = Math.floor((Math.random()*10)+0); super(game,arrEnemyX[vx],arrEnemyY[vy],sprite); this.scale.setTo(1.1, 1.1); this.frame = 9; game.physics.arcade.enable(this); this.body.collideWorldBounds = true; game.add.existing(this); this.body.allowGravity = false; this.effects = game.add.group(); for (var i = 0; i < 20; i++) { this.effect = this.effects.create(0, 0, 'effectRing', [0], false); this.effect.anchor.setTo(0.4,0.4); this.effect.animations.add('effectRing'); } } animate(l,r,u,d){ this.animations.add('left', l, 10, true); this.animations.add('right',r, 10, true); this.animations.add('up', u, 10, true); this.animations.add('down', d, 10, true); } see more in this proyect https://github.com/pardeep4e/Proyecto-DAW-2015-2016