Jump to content

Search the Community

Showing results for tags 'variables'.

  • 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 15 results

  1. Just going through the P3 tutorial "Making your first Phaser 3 game". I realized that "bombs" is not declared first as a variable, unlike "platforms", "player", etc. It functions with or without the declaration, so when is it necessary to declare the variable ahead of its first use?
  2. Having more Three.js experience where the general practice is to define your variables globally at the top, I'm getting used to keeping them local when that's all I need (most Babylon.js examples seem to do this), but I'm of course unable to inspect them in the browser console to look at the topology. This is a pretty general open-ended question, but mostly I'm wondering what's the best way to still be able to inspect when using local variables? I'm more generally wondering what's the best Babylon.js practices with respect to what I'm asking. Thanks!
  3. Hello every body I have question about using variables and "this". I am autodidact and I really like code and last 2 week I am trying make "simple" game but I am stuck. Here is my question : If I create js file and make there function: function Box(scene){ this.scene = scene; this.box = BABYLON.Mesh.CreateBox("box", 0.32, this.scene); this.boxMat = new BABYLON.StandardMaterial("mat",this.scene); this.boxMat.diffuseColor = new BABYLON.Color3(10,1,1); this.box.material = this.boxMat; }; And I have other js file whit other function which contains mesh like a sphere for example and now I want to use "this.box.position.x " in function where is the sphere. Is it possible ? I tried like function call() but it didn´t worked. I treid search in google some exampels and without success. Sorry for my bad English. Have a nice evening .
  4. Hello to all coders, I need to add same styling to multiple elements/variables. How i can write the code/syntax in Phaser so i do that with one line of code not 100s lines for same thing. For example basicTableJackpotSymbolOn.alpha = 0; game.add.tween(basicTableJackpotSymbolOff).to({alpha: 1}, 500, "Linear", true); basicTableBarSymbolOn.alpha = 0; game.add.tween(basicTableBarSymbolOff).to({alpha: 1}, 500, "Linear", true); basicTableMelonSymbolOn.alpha = 0; basicBetYellowRectV2N3Point.fill = '#999999'; basicBetYellowRectV2N4Point.fill = '#999999'; basicBetYellowRectV2N5Point.fill = '#999999'; basicBetYellowRectV2N6Point.fill = '#999999'; Thanks in advance.
  5. I'm doing a round based game. So after you've killed so many enemies it'll pop up, "Round 1", after some more, "Round 2" and so on. The amount of enemies doesn't change it's just the round that increases after you've killed say 20 enemies. I have a current variable at the top of my game.js file var currRound = 1; var EnemiesKilled = 0; Every time I kill an enemy I increment up the variable then in one of the collision handlers I do if EnemiesKilled == 20 then show some text newLevel.setText("Woo!! Round " + currRound + "!"); and restart the round via setTimeout(function() { game.state.start(game.state.current); }, 1000); The thing is, it whipes the variable of EnemiesKilled. How can I keep that variable so I always know how many enemies the player has killed?
  6. Hi, this is my code: for(var t = 0; t < edificios_texto.length; t++){ var loader = new BABYLON.AssetsManager(scene); //console.log(edificios_texto[n]); var edificio = loader.addMeshTask(t, "", "http://localhost:8080/modelos2/"+edificios_texto[t]+"/",edificios_texto[t]+".obj"); edificio.onSuccess = function (task) { //console.log(task.loadedMeshes.length); console.log(edificio.name); task.loadedMeshes.forEach(function(b) { b.scaling = new BABYLON.Vector3(5,5, 5); b.rotation.y = Math.PI; // cambiar las X var vertex_data = BABYLON.VertexData.ExtractFromMesh(b); for (var i = 0; i < vertex_data.normals.length; i+=3) { vertex_data.positions[i] *= -1; } vertex_data.applyToMesh(b); for (var i = 0; i < edificios.length; i++) { // console.log(edificios[i].texto); // console.log(t); if(edificios[i].texto == edificios_texto[t]){ var utmPlaceZ = edificios[i].x; var utmPlaceX = edificios[i].z; var utmPlaceXFromCentre = utmPlaceX - mapCentreX; var utmPlaceZFromCentre = utmPlaceZ - mapCentreZ; var x = utmPlaceXFromCentre/scaleX; var z = utmPlaceZFromCentre/scaleZ; b.position.x = x; b.position.z = z; break; } } }); } /* edificio.onFinish = function() { engine.runRenderLoop(function () { scene.render(); }); }; */ loader.load(); } I have to use the var edificios_texto[t] inside this function, How can I do it? JuanMa J.R
  7. pete796

    var vs. this

    Hello, Can someone explain why you would use a 'var' instead of 'this' ? In the example below variables are defined for 'var r' and 'var scale' buildSpaceRocks: function() { this.spacerockgroup = this.add.group(); for(var i=0; i<this.totalSpacerocks; i++) { var r = this.spacerockgroup.create(this.rnd.integerInRange(0, this.world.width), this.rnd.realInRange(-1500, 0), 'spacerock', 'SpaceRock0000'); var scale = this.rnd.realInRange(0.3, 1.0); r.scale.x = scale; r.scale.y = scale; this.physics.enable(r, Phaser.Physics.ARCADE); r.enableBody = true; r.body.velocity.y = this.rnd.integerInRange(200, 400); r.animations.add('Fall'); r.animations.play('Fall', 24, true); r.checkWorldBounds = true; r.events.onOutOfBounds.add(this.resetRock, this); } }, Many thanks
  8. I have a portion of my GUI created using the CastorGui extension. I've been trying to pass an object property from the colorSelector.getColor(); (r,g,b) values to another script (my main BJS script), as I have to keep the extension calls and functions in a seperate script. As a quick fix, I also tried to pass a global variable holding the parseFloat() (r.g.b) values, but I haven't had any luck passing these values using either method. What is the best method to pass these values - as well as to pass a CASTORGUI.GUISlider() value to a seperate script to use as a video slider control. I will also need to pass values back to my CasterGui script as well. Thanks for your help, DB
  9. Hey everyone, probably noob question, but I wanted to know what the best and safest practice for keeping global variables across states. Should I declare them as actual global variables, or as parameters of the game object? var game = new Phaser.Game(960, 540, Phaser.AUTO, 'game');var score = 0;var level = 0;//or something like thisgame.score = 0;Thanks!
  10. Hi I was wandering how to use a variable called game in a differenct java file than it was declared in. I know in basic java I could use something like public static game = *code here*but that doesn't work with Phaser for some reason. Declaring it as var game = *code here* how can i access it in a different file?
  11. Hey! I'm working further on with the first tutorial from Phaser, the platform game. I've changed a few things, such as different sprites. I'm trying to get a different image for the ground and the 2 platforms, but now my collision isn't working anymore... Also it won't show the platforms anymore. Complete beginner here, hope to get some help! Thanks in advance index.html
  12. thank you in advance, I am trying to control through variables like position and scaling... a rigged character with multiple meshes in a ,babylon file,"which was exported with animations from blender". The model is made up of three base objects "Creature", "eye", and "eye2". i need to be able to control the three meshes togeither as a whole. here is a clip of my code refering to this.... // Load character object BABYLON.SceneLoader.ImportMesh("", "models/", "creature.babylon", scene, function (meshes) { var c = meshes[0]; c.isVisible = true; c.scaling = new BABYLON.Vector3(0.1,0.1,0.1); c.position = new BABYLON.Vector3(0,3,0); //c.renderingGroupId = 2; c.checkCollisions = true; CREAT = c; }); window.addEventListener("keydown", function (evt) { switch (evt.keyCode) { case 67: createCreat(); break; default: break; } }); var createCreat = function () { var posX = LANES_POSITIONS[Math.random()]; var c2 = CREAT.clone(CREAT.name) c2.id = CREAT.name+(Creats.length+1); c2.isVisible = true; c2.position = new BABYLON.Vector3(Math.random() * 100- 50, 3, Math.random() * 100 - 50); };when i load this with the meshes[0] selection it only effects the eye... [1] = eye2... [2] = Creature... how can i select all 3 at once? i will need to be able to do this for the animation as well. ty for any help you can give.
  13. I created a group with the enemies on the screen. Now I would like to have each enemy hit points (some 2 others 3 others 4, etc ...). Then I thought that if there is way to make a kind of stretched groups phaser (and that he extended class could add a variable to the health points of each enemy ..?) Or do inthe Sprite class phaser .... I do not know how I should approach this. Any help or ideas? Thanks.
  14. I've been using this forum as a valuable tool along with all the wonderful examples provided to us. I finally have my first simple HTML5 game nearly complete but i'm having an issue with accessing the global variables in the Full Screen Mobile Template. I'll post the code I'm talking about below: Boot.js BasicGame = { // GLOBAL VARIABLES score: 0, // MUSIC THAT PLAYS BETWEEN STATES music: null, // CHECK AGAINST DEVICE ORIENTATION TO DETERMINE BEHAVIOR OF GAME orientated: false };BasicGame.Boot = function (game) {};BasicGame.Boot.prototype = { preload: function () { },Now, first I had noticed that in this template variables don't look like how I would normally declare a variable: var score = 0;In my loop timer I basically have the timer increment the score: Game.js updateCounter: function() { score++; scoreText.setText("Score: " + score); }If I use the above code without first declaring the score variable in this state then I get a variable undeclared error. My concept is that I want to add the score to the MainMenu state but when attempting to do so it states the variable is not declared. How would I access the global variable from another game state when declaring it as has been done in this template? Thanks for any help you can provide!
  15. Hello all, I'm having trouble updating 'diamondDropSpeed' from within the update function. I've included the relevant code below. 'diamondTotal' is being calculated elsewhere and is counting properly, and the code in the if statement fires properly... I just can't get the diamondDropSpeed value in the if statement to update globally. Any advice would be greatly appreciated. Thanks! BasicGame.Game = function (game) { diamondDropSpeed = 1000; };BasicGame.Game.prototype = { create: function () { diamonds = this.game.add.group(); diamondCreate = window.setInterval(function(){ diamond = diamonds.create(200, 0, 'diamond'); }, diamondDropSpeed); }, update: function () { if ( diamondTotal >= 1){ diamondDropSpeed = 200; } }};
×
×
  • Create New...