Search the Community

Showing results for tags 'require'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

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 6 results

  1. I received error when trying require babylon.js v3.2-alphaA. That normal in bjs previous (v3.2-alpha7). Log: Uncaught Error: Module name "babylonjs" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded at makeError (require.js:168) at Object.localRequire [as require] (require.js:1433) at requirejs (require.js:1794)
  2. I'm currently trying to get my first Phaser project working, fiddled around a whole day trying to get it all set up but since I'm completely new to writing bigger JS projects with modules, I have no idea how any of this works, even after googling and reading a million guides. I want to write TypeScript in VSCode. So first I installed phaser with npm install phaser --save Then I import Phaser in my app.ts with import Phaser = require("phaser-ce"); Did I pick the right syntax out of the 50 different ones? Whatever, this is the one I chose. So, while im coding I now got code completion and type hints working, but after compiling to JS, I now have multiple problems: First of all, the compiler adds code to my main JS file which tries to access a global module or exports object which obviously doesn't exist. Why? Why does it assume this exists? How can I turn this off? No idea. This is what it pastes righto onto line 2 of the main JS file: Object.defineProperty(exports, "__esModule", { value: true }); And since "exports" doesn't exist unless I hack it into the HTML file, it gives me an error. But now the more important question is... how exactly do I import Phaser? As far as I know you can't really import other JS files into another? (At least not in ES5 as far as I know). (Great, after switching my text color to an illegible light gray, forcing me to manually recolor all the text to black, now the text editor here creates a new paragraph instead of a new line everytime I press enter. Whyyyyyyy...........) In order to get code hints I need to import Phaser in my TypeScript file with the import statement, but if I use anything other than "module": "commonjs" in my tsconfig.json It can't find phaser anymore: // tsconfig.json // ... "compilerOptions": { "module": "commonjs", // ... // game.ts import Phaser = require("phaser-ce"); // WORKS // tsconfig.json // ... "compilerOptions": { "module": "anything other than commonjs", // ... // game.ts import * as Phaser from "phaser-ce"; // Can't use same syntax. Why? I don't know. // TypeScriptCompiler error: // Cannot find module 'phaser-ce' But of course commonjs doesn't work in the browser so... I tried instead to load the typings manually by copying the into /node_modules/@types/phaser and then instead of importing Phaser, instead referencing the typings with: /// <reference types="phaser"/> And including phaser.js in my index.htm But since Phaser itself has a bunch of dependencies that it tries to load with require() which of course doesn't exist and even if it did couldn't work, how am I supposed to do this correctly? It just whines about Pixi not being defined and some other stuff. I read http://phaser.io/tutorials/how-to-use-phaser-with-typescript but it never mentions how Pixi etc is supposed to be included and doesn't say anything about require, export, module errors, it just works apparently, but not for me. Which of the 50 different module systems does Phaser use, how does it export itself? RequireJS? AMD? UMD? ES6? ES2015? I have no idea how many different methods there are and how to tell which one is being used. How do I import it correctly? Do I need to manually add ALL *.js files of phaser into the <head> of my index.htm? This is all waaaaay too confusing....., help please Edit: I got a basic version working for now by just scrapping all the import stuff, setting tsconfig.json "module" to "none", adding a ///<reference types="phaser-ce"/> at the top of my game.ts and just including phaser.js in the html file. How it gets it's dependencies I still don't know but at least it works now. I also have no Idea where it gets the typings from, I guess it must be magic.
  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. Hello everyone, this is my very first post ! I am a french game developper student, and i like phaser and pixi it's very easy to develop with them. I try to use the ColorMatrixFilter of Pixi with Phaser to use the hueRotate on phaser's Groups. (I develop in Haxe with FlashDev by the way). I saw this thread : http://www.html5gamedevs.com/topic/5339-is-the-pixi-displacement-filter-available-in-phaser/ wich should answer my problem. But it's no use, here is what i have : at the beginning of the code (haxe is typed language wich export in javascript or other languages, but if you could help me in JS that should be enough) import phaser.core.Filter; private var hueFilter : Filter; //no problem for the moment ^^'' in the preload : game.load.script('ColorMatrixFilter', 'lib/pixi/filters/color/ColorMatrixFilter.js'); //--this give me an error : require is not defined in the create : hueFilter = untyped new PIXI.ColorMatrixFilter(); //--> this won't build flashDev tells me : Class not found PIXI and when i do this : untyped console.log(PIXI); //--> PIXI do exist! but there is no ColorMatrixFilter in it ! untyped console.log(PIXI.ColorMatrixFilter); //--> return undefined For the "require problem" i tried to use RequireJS in the index.html : <script src="lib/requireJS.js"></script> but it throws new error : Uncaught Error: Module name "../../core" has not been loaded yet for context: _. Use require([]) I believe i don't have to modify the ColorMatrixFilter.js to make it work so i don't know what to try next. I even try to use another filter (HueRotate.js) that i have found here : https://searchcode.com/codesearch/view/89062497/ //build with no error ! but completly erase my images and fill all the canvas with the same color... to sum up i can't make it work... It's very frustrating because when my project only used pixi it was very easy : filter = new ColorMatrixFilter(); container.filters = [filter]; filter.hue( value , false); Can someone please help me, it has been one week since i have this problem. what do i miss ? Thanks
  5. Hi everyone I named this post "Alternatives to organize code base into different files" because it is a more general than "alternatives to make modular code" or something like that. I like javascript a lot, but it being the ONLY LANGUAGE IN THE WORLD that does not have a way to load/reference a file from within another is what pisses me off most. Every language has it. C and C++ has "include", C# has "using", Java has "import" and php has "require" and "require_once". I bet even X86 assembly may have something like that. Nonetheless, javascript yet don't have it and only God knows if (and when) the ecmascript 6 draft that proposes modules like python's will come to really become standard and come the masses. And WHEN it come, will everyone use updated browsers ??? And, when it comes, people will already be familiar with what they are already familiar, like AMD (requirejs style modules) and browserify (commonjs style modules) That being said, I would like to know your experiences and opinions about how (and why) you divide your code base into several files. It seems most use browserify and others use requirejs. But there are still others that just define and use globals into several files and put several script tags in the html. I made an attempt to create what seemed to me the simplest way to emulate a include/import/using/require in javascript, using xmlhttprequest+eval to "include" synchronously one js file into another: https://github.com/Gnumaru/executejs I think the current ecmascript 6 draft propposal for modules is probably the best. But old javascript files meant to just be included in html with a script tag will probably need to be patched to work with the modules system. My solution is just a way to use the "old way" of adding several script tags, without really adding several script tags. I would like to know, then, what you're using to manage large codebases. Are you bundling every js file into one? with what? browserify? requirejs' bundling tool? linux's cat command? If you're not building your code base into one single file, how are you calling one file from anoter? several script tags? AMD (with requirejs or others)? something with commonjs sintax? And at last, independent of bundling your code into one file or not, how the functionality of each file is exposed to other files? by exporting amd style modules? exporting commonjs style modules? defining globals? defining namespaces? The creator of UglifyJS has given some thoughts on this matter wich is really worth reading. http://lisperator.net/blog/thoughts-on-commonjs-requirejs/ He says, for example, that for many years and still today, C programmers are used to define globals using unique names and are happy with it =) (those are not his words, those are my interpretation of his whole blog post) Your experiences and opinions would be really important to me and probably to several other people that may read this thread. Thanks.
  6. Was following a guide on using RequireJS with Phaser and my main.js starts like this: require(['lib/phaser.min','module/Player'],function(Phaser,Player){ var game = new Phaser.Game(1067, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }, false, false);And right away the console gives me the error "Uncaught TypeError: Cannot read property 'Game' of undefined" But if I try it with an older version of Phaser (the one provided with said guide, don't know how to check the version) it gets past that line. So are the new versions of Phaser incompatible with RequireJS or do I need to do something else?