Search the Community

Showing results for tags 'syntax'.



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. 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.
  2. I want to create 5 possible animations text instances that cycle through every time an action happens (like a button press for example). I am thinking this needs to be an array that increases the x position with a for loop (i++). What is the syntax for an array of text objects that can be cycled through with a for loop? Thanks in advance. Im new at pixi this is what I have so far: //Aliases: this is shorthand var Container = PIXI.Container, autoDetectRenderer = PIXI.autoDetectRenderer, loader = PIXI.loader, resources = PIXI.loader.resources, Sprite = PIXI.Sprite; //Create a Pixi stage and renderer and add the //renderer.view to the DOM var interactive = true; var stage = new Container(interactive), renderer = autoDetectRenderer(500, 500, { antialias: false, transparent: false, resolution: 1 }); document.body.appendChild(renderer.view); var btbTexture = PIXI.Texture.fromImage('https://res.cloudinary.com/dubyisimd/image/upload/v1481228417/buttonplaceholder_iit0dp.png'); var btn = new PIXI.Sprite(btbTexture); btn.scale.x = 0.5; btn.scale.y = 0.5; btn.anchor.x = 0.5; btn.anchor.y = 0.5; btn.position.x = 55; btn.position.y = 475; btn.interactive = true; btn.on('mousedown', () => console.log('mousedown')); stage.addChild(btn); //load an image and run the `setup` function when it's done loader //add images by: //.add("images/beerCup_logo.png") .add("https://res.cloudinary.com/dubyisimd/image/upload/v1481228417/buttonplaceholder_iit0dp.png") //creates a progress statement that will check to see if assets are loading .on("progress", loadProgressHandler) .load(ScrollingText, addButton); //.load(); //this function will check to see if all assets are loading to the stage. loader function loadProgressHandler(loader, resource) { //Display the file `url` currently being loaded console.log("loading: " + resource.url); //Display the precentage of files currently loaded console.log("progress: " + loader.progress + "%"); //If you gave your files names as the first argument //of the `add` method, you can access them like this //console.log("loading: " + resource.name); } //button: function addButton() { button = new sprite(resources["https://res.cloudinary.com/dubyisimd/image/upload/v1481228417/buttonplaceholder_iit0dp.png"].texture); stage.addChild(button); button.x = 15; button.y = 15; } //text scroll: function ScrollingText() { //Im thinking this is where the array of 5 possible text positions should be text = new PIXI.Text('This is a pixi text', { fontFamily: 'Oswald', fontSize: 24, fill: 0xff1010, align: 'center' }); stage.addChild(text); text.x = 500; text.y = 0; gameLoop(); } function gameLoop() { requestAnimationFrame(gameLoop); text.x -= 1; renderer.render(stage); }
  3. Hi all. I am wondering why there is such extensive usage of the "this" keyword in the "Full Screen Mobile" project template (included with Phaser, I am using v2.4.4). Code sample from 'Full Screen Mobile' project template: BasicGame.Boot.prototype = { init: function () { this.input.maxPointers = 1; this.stage.disableVisibilityChange = true; this.stage.backgroundColor = '#000000'; if (this.game.device.desktop) { this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.setMinMax(160, 240, 640, 960); this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; } else { this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.setMinMax(160, 240, 640, 960); this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; this.scale.forceOrientation(true, false); this.scale.setResizeCallback(this.gameResized, this); this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this); this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this); } }Code sample from phaser.io 'examples': var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });function preload() { game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');}var s;function create() { s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot'); s.anchor.setTo(0.5, 0.5); s.scale.setTo(2, 2); s.animations.add('run'); s.animations.play('run', 10, true);}What difference does this make? Why do I have to use it? Is it considered 'best practice'? Does it affect anything if I don't include it?
  4. Hi guys, i'm having trouble with this code , the error is "Cannot read property 'velocity' of null" in player.body.velocity.y = Math.abs(playerSpeed); <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Drop Wizard</title> <script type="text/javascript" src="phaser.min.js"></script> <style type="text/css"> body { margin: 0; } </style></head><body><script type="text/javascript">var game = new Phaser.Game(480, 320, Phaser.CANVAS, '', { preload: preload, create: create, update: update });var playerSpeed = 150;var player;var platformGroup;function preload() { game.load.image("platform180","platform180.png"); game.load.image("platform120","platform120.png"); game.load.image("player","player.png"); game.load.image("ground","ground.png");}function create() { platformGroup = game.add.group(); game.physics.startSystem(Phaser.Physics.ARCADE); player = game.add.sprite(240,0,"player"); player.anchor.setTo(0.5); game.physics.enable(player,Phaser.Physics.Arcade); game.physics.arcade.gravity.y = playerSpeed; addPlatform(240,60,"platform180"); addPlatform(340,140,"platform120"); addPlatform(140,140,"platform120"); addPlatform(420,220,"platform120"); addPlatform(60,220,"platform120"); addPlatform(100,316,"ground"); addPlatform(380,316,"ground"); game.input.onDown.add(changeDir,this);}function addPlatform(posX,posY,asset){ platform = game.add.sprite(posX,posY,asset); platform.anchor.setTo(0.5); game.physics.enable(platform,Phaser.Physics.ARCADE); platform.body.allowGravity = false; platform.body.immovable = true; platformGroup.add(platform);}function update() { player.body.velocity.y = Math.abs(playerSpeed); player.body.velocity.x = 0; player.body game.physics.arcade.collide(player, platformgroup, movePlayer); if(player.y>320){ player.y = 0 } if(player.x<12){ player.x=12; playerSpeed*=-1 } if(player.x>468){ player.x=468; playerSpeed*=-1 }trace(player); trace(player.body) trace(player.body.velocity)}function movePlayer(){ player.body.velocity.x = playerSpeed} function changeDir(){ playerSpeed *= -1; }</script></body></html>
  5. Hi, I'm new to programming and trying to learn webGL using the playground on babylon js. The site is really good and seem to help me with learning about babylon js and webGL. I'm trying to modify camera target: camera.setTarget(BABYLON.Vector3.Zero()); to some other coordinate, for e.g. camera.setTarget(BABYLON.Vector3.(0, 0.2, 0)); This doesn't seem to work. Any ideas? I tried to search for some documentation that gives some examples on the various syntaxies but couldn't find any for a beginner level. Thanks.
  6. How come you can write this: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });function create() {var text = "hello world";var style = { font: "65px Arial", fill: "#ff0044", align: "center" };var t = game.add.text(game.world.centerX-300, 0, text, style);}And it behaves the same as this: main.js var test = test || {};test.game = new Phaser.Game(600, 400, Phaser.AUTO, '');test.game.state.add('Game', test.Game);test.game.state.start('Game');game.js var test = test || {};test.Game = function(){};test.Game.prototype = { create : function () { var text = "hello world"; var style = { font: "65px Arial", fill: "#ff0044", align: "center" }; var t = this.game.add.text(this.game.world.centerX-300, 0, text, style); }};Why is the syntax different?