sebamawa

Members
  • Content Count

    13
  • Joined

  • Last visited

  1. sebamawa

    WebStorm2016.2+Phaser+error with require()

    Thank you very much Luiz, I was not using npm to download the libraries of Pahser, I did it directly from the web. That tutorial had seen it. The problem is with the import of the require () function. If I can solve it I say it here, regards
  2. sebamawa

    WebStorm2016.2+Phaser+error with require()

    Thanks Luiz, The problem is that I do not know what library to import. What's more, I do not have the node_modules directory in the project. To add it to a Phaser project? Back time worked with javascript hard, but now Typescript feel more comfortable, but right now I'm a little lost.
  3. Friends, greetings to all. Return to Phaser after a while. I'm working with WebStorm and TypeScript. I have a problem with importing a class into a .ts (typescript) file: Import EnemySprite from './classes/EnemySprite'; Translated to javascript: Var EnemySprite_1 = require ( './ classes / EnemySprite'); The require () function is not recognized, so when I run the game I get the following message in the index.html: Uncaught ReferenceError: require is not defined Some help? Thank you!
  4. sebamawa

    Phaser OOP examples

    Hello, good point, Here, in the examples of Phaser: http://examples.phaser.io/ Examples 'extended sprite demo 1' and 'extended sprite demo 2' (in Sprite section) can guide you. For example ('extended sprite demo 1'): // Here is a custom game object (constructor)MonsterBunny = function (game, x, y, rotateSpeed) {Phaser.Sprite.call(this, game, x, y, 'bunny');this.rotateSpeed = rotateSpeed;};MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype);MonsterBunny.prototype.constructor = MonsterBunny;/*** Automatically called by World.update*/MonsterBunny.prototype.update = function() {this.angle += this.rotateSpeed;};You can initialize the attributes of the 'class' in the constructor, and place the corresponding actions in the function update (), also add the methods you need. All this in a javascript file (here is your 'class' js), then from another file you can instantiate an object MonsterBunny with: var mb = new MonsterBunny(game, x, y, z); (for example), and use this object in the World.update() function.
  5. sebamawa

    Group Positioning

    The remaining children of the group? you create just one (f). Or whatever you want to render all frames of spritesheet (sprite123.png) with spaces, like you mentioned above?
  6. sebamawa

    Group Positioning

    What kind of object is your group? (game object) Once rendered, all behave the same? I think what you want can be done by programming, but I need more info, or some code. Regards
  7. sebamawa

    Group Positioning

    To clarifying ideas: sprite1, space, sprite2, 2*space, sprite3, 3*space, ... Correct: sprite1, space, sprite2, space, sprite3, space, ... So something is what you want?
  8. Evident my friend lewster32, thanks
  9. Hi friends! Definitely, the best way to work with collections of objects (enemies, obstacles, etc) is extend the Sprite class and to work with Groups (at least for me). In the examples on extending the Sprite class, we have: /** * Automatically called by World.update */MonsterBunny.prototype.update = function() { this.angle += this.rotateSpeed;};I can automatically call World.create function as above? to initialize the behavior of objects, and not make the call explicit to create function. Thanks, and excuse me for my english This, not work: MonsterBunny.prototype.create = function(){ ...};
  10. Exactly InsaneHero, Yes, best idea is to extend the Sprite class. Thanks friends, this is a good comunity.
  11. Hello friends, First, as usual, excuse me for my english, I need destroy a object (from a class) at the time when the sprite asociated (property of the object) is delete (with kill()) How I can do? Example: var obj = new ObjClass(); //obj.objectSprite is a property (a Sprite) function update(){ game.physics.aracade.collide(obj.objectSprite, otherSprite, destroyObject, null); } function destroyObject(){ obj.objectSprite.kill(); //Here, I want to destroy the object that has 'this.objectSprite' as property (or attribute) //The natural solution is do obj = null }
  12. Thanks Sam, But, the problem is that I don't know the index of the child. Is possible obtain a reference to child in a collision, without know the index? Regards, Edit: Here, the solution (found in the forum): http://www.html5gamedevs.com/topic/10418-get-the-one-sprite-within-group-that-collided-overlapped/?hl=group%2Bcollision Thanks all,
  13. Hello all! First. excuse me for my english. I need to get a reference to child of a group, this in the collide function of Arcade system. Example: function update(){ collide(spritePlayer, groupPlatforms, collideCallback, processCallback, callbackContext);}I will think do some this:function collideCallback(){ //the problem is I have no functions to retrieve the child of the groupPlatforms (I have getAt(index) and getIndex(child) for example)}Any help is appreciated.