Jump to content

Search the Community

Showing results for tags 'parameters'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 8 results

  1. I have created a BoxGeometry and then added it to a Mesh. The problem is that no matter what size a give it, it always gets rendered as size=1. I also created a box using BABYLON.MeshBuilder.CreateBox(), and there it works fine, size is updated as expected. Here's the PG: http://playground.babylonjs.com/#UUJWXS Problem is at line 14: var box = new BABYLON.BoxGeometry('box', scene, 8, true, mesh, 4); as you can see size is set to 8, but actually it gets rendered smaller the the other box which has size 4.
  2. Hi! I can access the x parameter on this.draw() function, why it doesn't work on this.updateRotation()?? After I create a Shooting Module on my game loop I can access the getX(). What I am missing? function ShootingModule(_canvas){ this.x = 200; this.y = 500; this.radius = 16; this.rotation = 0; this.canvas = _canvas; this.color = "blue"; this.draw = function (context){ context.beginPath(); context.translate(this.x, this.y); context.rotate(this.rotation * Math.PI / 180); context.arc(0, 0, this.radius, 0, Math.PI * 2, true); context.fillStyle = this.color; context.fill(); context.fillRect(-6, -this.radius -6, 12, 12); context.stroke(); context.setTransform(1, 0, 0, 1, 0, 0); }; this.updateRotation = function(e){ console.log(this.x); this.rotation = Math.atan2(e.clientY - this.y, e.clientX - this.x); }; this.update = function(){ }; this.getX = function(){ return this.x; }; } In my main loop script: playerShootingModule = new ShootingModule(canvas); canvas.addEventListener('mousemove', playerShootingModule.updateRotation, true);
  3. 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?
  4. Hey guys, I got a weird behavior from using the callback method on group.onDestroy: this.playerCar = 'car1'; this.enemyCar = 'car2'; this.optionsGroup.onDestroy.add(this.currentTrack.createCars, this, 0, this.playerCar, this.enemyCar);
  5. Hey guys, I got a weird behavior from using the callback method on group.onDestroy: this.playerCar = 'car1'; this.enemyCar = 'car2'; this.optionsGroup.onDestroy.add(this.currentTrack.createCars, this, 0, this.playerCar, this.enemyCar); and what I get on the other side instead of 'car1' and 'car2', is: [object, object] and true. I even tried using: this.currentTrack.createCars.bind(this), but it does not help Does anyone know why? Phaser version 2.6.2
  6. Hello, I am relatively new to both JS and Phaser so bare with me. I have run into a problem with animating an object from one point to another and then wait for a mouse click and then move back to the original position. So I am trying to create a chain of tweens and also adding an eventlistener in the middle to wait for a mouseclick before continuing the tween chain. And through this chain I need to pass the object (card) that I am doing animations on. The problem at the moment is that I want to send a parameter with the eventlistener from clickCallback to clickWait. function clickCallback(currentCard) { this.addEventListener("click", clickWait(currentCard), false); } function clickWait(cur) {//Here is the problem, I can get the eventlistener or the argument, not both.. removeEventListener("click", clickWait); //... } function clickCallback(currentCard) { this.addEventListener("click", clickWait, false); } function clickWait(e) {//Same as above but I get the event removeEventListener("click", clickWait); //... } I did a ugly solution earlier which worked, but it was not practical. I also recently found out how functions that you add with onComplete/onStart send arguments which made me think I could solve it in another fashion. Is there anyway to solve this, or do I have to stick with my ugly solution? Full code below (at least the relevant stuff): function moveCard(card, tutoBox) { var tempGroup = card.parent; var tempPositions = [{x:card.position.x,y:card.position.y},{x:card.paired.position.x,y:card.paired.position.y}]; var cards = []; cards.push(card); cards.push(card.paired); var tweenList = createCardTweens(card,tutoBox.position,30,90); for(var i = 0; i < tweenList.length; i++) { tweenList[i].onStart.add(scaleCard, this); tweenList[i].start(); objGroup.addChild(cards[i]);//Moves the selected card infront of tutoBox tweenList[i].onComplete.add(clickCallback, this); } function scaleCard(currentCard){ var scaleCard = game.add.tween(currentCard.scale); if (currentCard.scale.x === 1.125 || currentCard.scale.y === 1.125) scaleCard.to({x: 0.7, y: 0.7}, 450, Phaser.Easing.Linear.None); else scaleCard.to({x: 1.125, y: 1.125}, 450, Phaser.Easing.Linear.None); scaleCard.start(); } function clickCallback() { addEventListener("click", clickWait, false); } function clickWait(e) { removeEventListener("click", clickWait); for (var i = 0; i < cards.length; i++) { var cardMoveBack = game.add.tween(cards[i]); cardMoveBack.to(tempPositions[i], 500, Phaser.Easing.Linear.None); cardMoveBack.start(); } cardMoveBack.onStart.add(scaleCard,this); cardMoveBack.onComplete.add(function(currentCard){ tempGroup.addChild(currentCard); cardsManager.enableClickAll(); tutoBox.destroy(); },this); } }
  7. Hi! I am trying to do a new plugin but I don't know why this piece of code doesn't work. I reduced my real code to a basic case,so it will be easy to understand. I have a problem with the functions setTexture and setColor. Although I pass as a parameter the object that I want to modify, when the function returns the object is inmutable, the state is the same that it was before calling the function. For example "this.bitmap" is an empty object after call "setTexture()", but I worked over him inside the function. Someone can help me with this? I think maybe it will be a scope problem but I can't find an explanation. You can see the working code in the following fiddle: https://jsfiddle.net/p78bzn9w/5/ . In the console you can also view the behaviour of the values that I described or you can see the code here: Phaser.Plugin.Virtual = function(game, parent) { Phaser.Plugin.call(this, game, parent); this.game = game; }; Phaser.Plugin.Virtual.prototype = Object.create(Phaser.Plugin.prototype); Phaser.Plugin.Virtual.prototype.constructor = Phaser.Plugin.Virtual; Phaser.Plugin.Virtual.prototype.setup = function (player, buttons){ this.bitmap = {}; //here this.bitmap is {}, I pass as the first parameter this.setTexture(this.bitmap, '#4BAFE3', 30, 30); //after return setTexture, this.bitmap is {} again but it would be a bitmap this.arrow = {}; //here this.arrow is {}, I pass as the first parameter too this.setColor(this.arrow, 10, 20, this.bitmap , 0.5, 90); //the same problem as before, this.arrow is {} but it would be a button } Phaser.Plugin.Virtual.prototype.setTexture = function (item, color, width, height){ //I create a bitmap in item //item is this.bitmap var item = this.game.add.bitmapData(width, height); item.ctx.fillStyle = color; item.ctx.fillRect(0,0,width, height); //here item is a bitmap }; Phaser.Plugin.Virtual.prototype.setColor = function (item, x, y, bitmap, alpha){ //I create a button in item //item is "this.arrow". item = this.game.add.button( x, y, bitmap); item.alpha = alpha; item.fixedToCamera = true; //here item is a button }; Thanks so much!
  8. Hi guys, Maybe a silly question, but I recently started using States in my game and now I am converting my functions to work with states. The functions without parameters work fine, but the ones with parameters don't. For example, when I call: this.createBullet(x, y); I get the error: Uncaught typeError: undefined is not a function. The function createBullet(x, y) does exist, it is created like this: createBullet: function(x, y) { // blablabla content of function } p.s. these functions are in my Game.js state Can anyone tell me what I'm doing wrong? It has to be a silly mistake but I don't know how to fix it Thanks, Kevin
×
×
  • Create New...