Jump to content

Search the Community

Showing results for tags 'global'.

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

  1. Given a vector expressed in global space and a mesh, how can I get the position of this vector within a mesh local space? Or, alternatively, how can I get a parent position within a child local space? Update: Just figured it out... It is simply vector.subtract(Mesh.getAbsolutePosition()), right? Update2: Ok it's not... Because it doesn't take in account the mesh rotation.
  2. I have a global object called "params" that stores a lot of important parameters for my game. I define params in a "main.js" file that initializes the game, defines my states and parameters, and then calls my "bootState". For some reason, when I restart my "gameState" (another state, defined in "gameState.js") it resets my "params" object to the values it was initialized with in "main.js". My goal is to change some parameters via "params" in the console, then restart "gameState" and have it reflect those changed parameters. If needed I can provide some example code.
  3. Currently I have a group of sprites and I want to make them all fall at the same time. I am trying to accomplish this with the following functions, where the group (here: fallGroup) should fall when the down arrow key is pressed. (and yes, I have already initialized keys in the create() method) I have tried passing multiple versions of the function definition to callAll() (eg. "this.setVel", "game.setVel", ect.) as well as several different contexts instead of 'null' ("this", "that=this, then passing 'that' in", "game", "game.stage", ect.) but so far nothing happens. For some of the combos I get "TypeError: Cannot read property 'setVel' of undefined" others produce no error but also do not call my 'setVel' function. At this point I'm pretty lost as to what to do. Edit: appleYpos, groundYpos, appleTime; are all globally defined variables function setVel(sprite,vel) { sprite.body.velocity.y = vel; } function makeFall(group) { //calculate fall distance and then adjust velocity to meet time goal //note: velocity in physics.arcade is in pixels/sec let dist = appleYpos - groundYpos; let vel = dist/appleTime; group.callAll('setVel',null,vel); } function update() { if(keys.down.isDown) { makeFall(fallGroup); } }
  4. Hello ! I really want to read the source code of phaser, but I am not that professional. the namespace Phaser is declared inside a function, so I am wondering how we can access it outside it ? (function(){ var Phaser = Phaser || {}; }).call(this); Phaser.something = 5; //Reference error, Phaser is not declared what things I ca learn to read the source code perfectly and have this awesome experience ?
  5. Hello, I read in the doc that rotation is achieved before translation, but I try to have an offsetted object rotate around the 0,0,0 axis and I cant find any way to achieve this ... usualy(with other engines) I offset the object on its local axis then simply rotate it globaly with a matrix/quaterion/rotate function I tried different combinations of these two mesh.translate(BABYLON.Axis.X, 3.0, BABYLON.Space.WORLD); //or LOCAL mesh.rotate(BABYLON.Axis.Y, 1.0, BABYLON.Space.WORLD); //or LOCAL (I wanted to rotate the object position with a quaternion, but the Quaternion lacks of regular/usual .mult(Vector) or .rotate(Vector) and anyway, it wouldn't be what I want to achieve) any idea ? thanks
  6. I am currently manipulating a series of ground objects. I am able to manipulate the ground with different noise effects and calculations to get the effects I am desiring on a single ground plane. The problem when I am doing it with the series of them they are all effectively getting the same manipulation applied. I am generating the ground objects in a block so they are all one right after another and look like a single plane, so they all have an offset in the global space. How then can I convert the point from its local assignment in the script: TERIABLE.UpdatePositions = function (positions) { for (var idx = 0; idx < positions.length; idx += 3) { positions[idx+1] = positions[idx]*positions[idx+2]; } }; //Section where it is called: this._block.updateMeshPositions(TERIABLE.UpdatePositions); to a global position. I might be able to do it by adding the grounds.position.x and y to the idx values? but I have not tried that yet and I am not even sure how to pass the ground object with the positions on the updateMeshPositions call i see no optional variable offset in http://doc.babylonjs.com/classes/2.3/Mesh
  7. Hey there, I'm new to javascript and I'm trying to figure out how to create a global singleton for generic functions. I can create global variables in the Boot state, but I'd like to create an object that holds global vars and functions. I'm instancing a custom GameManager script in the index.html file like so: //initialize framework var game = new Phaser.Game(640, 960, Phaser.AUTO, 'game'); //create global object var gameManager = new GameManager(); My GameManager.js file looks like this: var GameManager = function GameManager() { console.log('game manager created'); this.myName = "adrian"; this.GetName = function() { console.log("my name is "+this.myName); } }; The problem is gameManager object is undefined elsewhere in game. Any suggestions? Thanks
  8. I'm very new to Babylon.js and have spent a few days reading through the docs and forums, but I haven't been able to find a good answer for this. Let's say I have a rotating and scaled cube in my scene and I want to get the absolute position of each vertex. I found this topic for translating world coords to screen coords: http://www.html5gamedevs.com/topic/9584-converting-3d-vertex-to-2d-point-on-screen/ but so far I can only figure out how to get the position of the mesh itself, not for its vertices. In fact, even after digging around in the mesh object, I can't even find where the vertices are stored. How do I get the coordinates of a mesh's vertices so that I can translate them to screen coords so I can draw debug lines on a canvas?
  9. Hi, I just creating pinball game with Phaser... I'm using P2 physics. I have one sprite BALL: this.ball = game.add.sprite(x, y, 'ball'); game.physics.p2.enable(this.ball, false); this.ball.body.setCircle(10); this.ball.body.fixedRotation = true;But in one case I need to make this ball to ignore collisions with all elements... (ball should to pass through other sprites without collisions) I just need to turn off gravity, collision and then randomly move ball to different place and then turn gravity/collisions ON. I'm trying to create ball movement in rails above other elements.
  10. 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!
  11. 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...