Théo Sabattié

Members
  • Content count

    30
  • Joined

  • Last visited

About Théo Sabattié

  • Rank
    Advanced Member
  • Birthday 09/11/1994

Contact Methods

  • Twitter
    theoSabattie

Profile Information

  • Gender
    Male
  1. I am not sure to understand... Do you want the list reference in each object in it? like var list = [ { id: 'base', prop: 'base_something', myList: // == list }, { id: 'somethingelse', prop: 'anotherprop', myList: // == list }, { id: 'somethingelse42', prop: 'anotherprop42', myList: // == list }, ] ? If it is that, you can do: var list = []; function ListElement(parameters){ // replace name making sens this.list = parameters.list || []; this.list.push(this); this.prop = parameters.prop || "defaultProp"; this.id = parameters.id || "defaultId"; // your own properties instantiation } new ListElement({ list : list, prop : "hello", id : "world" }); Or do you want that the last object of your list have the same property of the first element? Do you want that the last object has alway the same property of first? (if first remove, take new property of new first. If last remove, set property of first on new last ?)
  2. remove ',' at the end
  3. Position is always based on parent.
  4. Hi'' You have to cast your htmlElement: this._canvas = <HTMLCanvasElement> yourHtmlElement; this._canvas = yourHtmlElement as HTMLCanvasElement;
  5. Don't be worry, that is not mine too. I am not sure to understand Why don't you update directly the position ? I don't understand where the conflict come from.
  6. I doubted so I set parenthesis, but you can remove them for that: this.game.input.onDown.add(function(e) { if(e.position.x < this.game.width/2) { moveDirection = -1; } else { moveDirection = 1; } this.player.body.velocity.x = xSpeed * moveDirection; }.bind(this)); In your case, you apply the bind on the add returnment this.game.input.onDown.add( function(e) { /* ... */} ).bind(this); I don't know if add method returns something, but that is not the place to use bind. You have to bind your own object on the callback : this.game.input.onDown.add( function(e) { /* ... */ }.bind(yourObject) ); In this case, this is the Main instance. But if you want, you can bind directly this.player.body.velocity and update x inside callback: this.x += /*..*/ But it will become hard when you will proofread your code to know what "this" represents.
  7. this.game.input.onDown.add(function(e) { if(e.position.x < this.game.width/2) { moveDirection = -1; } else { moveDirection = 1; } this.player.body.velocity.x = xSpeed * moveDirection; }); In callback, or event callback, object is often bind in function (as this); function explanationBind(){ console.log(this); } var lObject = {a:"hello"}; explanationBind.bind(lObject)(); // lObject in console explanationBind(); // Window object in console If you want your object in this method (as this), you have ton bind your object: this.game.input.onDown.add((function(e) { if(e.position.x < this.game.width/2) { moveDirection = -1; } else { moveDirection = 1; } this.player.body.velocity.x = xSpeed * moveDirection; }).bind(this));
  8. Ok'', you can add that: #myCanvas { /* ... */ z-index : -1; }
  9. I am not sure but I think you wanted to write : <body> <input type="button" value="button 1"> <input type="button" value="button 2"> <h1>Hello</h1> <canvas id="myCanvas" width="256" height="256"></canvas> </body> Use this css: #myCanvas { margin: 0; padding: 0; position: fixed; touch-action: none; width: calc(100% - 2px); /* for borders */ height: calc(100% - 2px); /* for borders */ border: 1px dashed; top:0; left:0; }
  10. The score is incremented by 1 every 7 seconds. When missile explodes on collision with a mine, that increments the score by 5 @lemmo gets the best score for the moment. Is there an other challenger?
  11. https://pixijs.github.io/docs/PIXI.DisplayObject.html See : toLocal method.
  12. I suppose the error comes from game.physics.arcade.overlap(player, cake, this.getItem); ? In callback, or event callback, object is often bind in function (as this); function explanationBind(){ console.log(this); } var lObject = {a:"hello"}; explanationBind.bind(lObject)(); // lObject in console explanationBind(); // Window object in console If you want your object in this method (as this), you have ton bind your object: game.physics.arcade.overlap(player, cake, this.getItem.bind(this));
  13. That seems tricky ahah. you have to split each charater : yourString.split(""); Create one text by character and set right position.
  14. Do you want split a string? Or do you want make a line feed on pixi's text? to make a line break you can use breakWords, wordWrap and wordWrapWidth on text style or just write a "\n" in your text "Hello\nworld" will become "Hello world"