Search the Community

Showing results for tags 'platforms'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Found 9 results

  1. Help with scales?

    So I've been following along with a tutorial to make my first game in Phaser. I'm trying to understand everything the tutorial is saying, but I can't find an explanation for everything. For example, the background image being used in the game is 400x32. However, the tutorial says the following: // Scale it to fit the width of the game (the original sprite is 400x32 in size) ground.scale.setTo(2, 2); My question is this; if the original size is 400x32, then why does seting the ground scale to 2, 2 work out? The game made in the tutorial works, and the ground does fit the width, but wouldn't the ground have to be 400x2 or something like that to have the proper width? I'll attach the tutorial file to this post so you can see the whole thing. I attached the tutorial text itself, and "part9.html" is the completed code that came with the tutorial. I don't think my code is needed to answer my question because I'm just following along with the tutorial, and it's just a less completed version of part9.html. I also have one more question regarding the ground. The tutorial says this: // Here we create the ground. var ground = platforms.create(0, game.world.height - 64, 'ground'); Again, if the size is 400x32, then why does -64 work to put the ground at the bottom? What does 64 do in this code? I guess I'm just looking for an explanation of why the code I posted works. I understand the rest of the code in the file, just these 2 lines are what confuse me the most. I'd greatly appreciate any help I can get, thanks! Edit: I realize now that in the first line of code I pasted here, the 400x32 is talking about the size of the platform itself, not the whole background. Still, how does the (2, 2) scale a 400x32 platform to fit the whole background? tutorial.html part9.html
  2. Shower visualization

    Hi everybody: These days I'm starting with a development involving the visualization of a shower. The software must run in desktop and mobile (this last by means of an hybrid app). In order to show the (falling) water I'm considering two strategies: chroma-keyed video with the water falling (I'm using both a mp4 and a webm containers); particles (I'm afraid of As I am concerned about the performance penalty of using particles (it needs 30,000+ and motion blur in order to resemble a "real" shower), we are tackling first the video way. Running a raw example from server, over Chrome (Win) and Safari (OSX), shows the alpha 100% clear: With Firefox (Developer Edition / 56.0b1) the alpha channel is instead shown with a degree of opacity: Do you think is possible to obtain a correct alpha in this last browser? Best regards.
  3. Detect platform that sprite is on

    I am creating a platforming game that has multiple different platforms. Some platforms slope up and others slope down. Upward Sloping Platforms * If the character moves right, his y position will increase * If the character moves left, his y position will decrease * The angle property of these platforms is negative Downward Sloping Platforms * If the character moves right, his y position will decrease * If the character moves left, his y position will increase; * The angle property of these platforms is positive The following tries to find the colliding platform. My update function looks something like this game.physics.arcade.collide(hero, platforms, function() { currentPlatform = platforms.children.filter(p => p.getBounds().contains(hero.x, hero.y))[0]; gameState.moveRight(); gameState.moveLeft(); }); } I need this platform to calculate whether the character will move upwards or downwards. Here is an example if (cursors.right.isDown) { if (currentPlatform) { hero.y = currentPlatform.angle < 0 ? hero.y - 0.04 : hero.y + 0.04; } } This obviously doesn't work, and the 0.04 value is hard coded, because I can't figure out how to increment with an angle. I've also tried calling sprite.body.touching, which returns the following Object {none: true, up: false, down: false, left: false, right: false} I am completely lost right now.
  4. Hi, I'm writing a platform game in phaser, but the limits of the platforms don't seem to be the same as the limits of the image, so my player can keep walking "in the air" even when there's no platform under him. I`ve attached an image, as you can see there's no cloud under the player, but he`s standing on it anyway, he can walk this far untill fall to the platform below. Here is the "preload()" code part : this.load.image("cloud", "assets/cloud.png"); And here the "create()" code part: this.cloudsData =[ {"x":0 , "y":750}, {"x":200 , "y":600}, {"x":0 , "y":450}, {"x":200 , "y":300} ]; this.clouds = this.add.group(); this.clouds.enableBody = true; this.cloudsData.forEach(function(element){ this.clouds.create(element.x, element.y, "cloud"); }, this); this.clouds.setAll("body.immovable", true); this.clouds.setAll("body.allowGravity", false); I've tried changing the image with the same result, i think the code is wrong but i don't know where. Many thanks.
  5. Hello, I have created a simple top-down game with a tiled map for a frogger-like game where i can move my character arround. I now want to implement moving platforms for my character to advance, i want to spawn my platforms on a specific group of tiles, (since this is a frogger game, you could guess i want to spawn logs on water tiles) i have done some research and couldn't really find what i was looking for in the examples and the forum. I would like some advice on the way to proceed in my project, as i am kind of lost Is it possible to generate my platforms using the json data to identify the water tiles? Do my platforms have to be Tile objects or can i create them in the game so i can freely use them? I'll gladly take your advice
  6. Player not jumping in platforms

    I'm having a problem in my game that i cant make my player jump when he is on an platform. Can anyone help me, here is the code (i dont know what part is wrong so i'll put the full code) Ps: I'm using phaser 2.3.0, and i dont speak english very well, so sorry if i write something wrong. game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = '#000000'; game.world.setBounds(0, 0, 4000, 400); campo = game.add.tileSprite(0, 0, 4000, 400, 'fundo'); cursors = game.input.keyboard.createCursorKeys(); jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); game.physics.arcade.gravity.y = 100; player = game.add.sprite(100,300 , 'boneco'); game.physics.arcade.enable(player) player.body.collideWorldBounds =true; player.animations.add('frente' , [0,1,2], 4); player.animations.add('tras' , [3,4,5], 4); player.animations.add('puloe' , [6]); player.animations.add('pulod' , [7]); player.animations.add('parado' , [8]); game.camera.follow(player); platforms = this.add.physicsGroup();platforms.create(50, 350, 'terra');platforms.create(200, 180, 'terra');platforms.create(400, 296, 'terra');platforms.create(600, 412, 'terra');platforms.setAll('body.allowGravity', false);platforms.setAll('body.immovable', true);platforms.setAll('body.velocity.x', 0)platforms.setAll('body.velocity.y', 0)platforms.setAll('body.collideWorldBounds', true); }, update: function () { player.body.bounce.y = 0.2; player.body.gravity.y = 200; player.body.velocity.x = 0; if (cursors.left.isDown) {player.body.velocity.x = -150; if (facing != 'left') { player.animations.play('tras'); facing = 'left'; }} else if (cursors.right.isDown) {player.body.velocity.x = 150; if (facing != 'right') { player.animations.play('frente'); facing = 'right'; } } else {if (facing != 'idle') {player.animations.play('parado'); facing = 'idle';}} if (jumpButton.isDown && player.body.onFloor() && game.time.now > jumpTimer) { player.body.velocity.y = -250; jumpTimer = game.time.now + 750;} if (jumpButton.isDown && player.body.onFloor() && game.time.now > jumpTimer) { player.body.velocity.y = -250; jumpTimer = game.time.now + 750;} game.physics.arcade.collide(platforms, player)
  7. Jumpthrough platforms causing bouncing

    I'm trying to create a game that involves platforms I can jump through and land on top of. However, when I jump through a platform and land on it, I bounce on top of the platform. The bouncing has to do with the height I dropped from onto the platform. In order to do the jumpthrough platforms, I used the ideas from this thread, and modified them to work with my game. The actual code I'm using in the onPreSolve method is below: world.on('preSolve', function(presolve) { for (var i = 0; i < presolve.contactEquations.length; i++) { var c = presolve.contactEquations[i] var f = presolve.frictionEquations[i]; if (c.bodyA.shapes[0].collisionGroup == GROUND || c.bodyA.shapes[0].collisionGroup == PLATFORM) { var yAxis = p2.vec2.fromValues(0, 1); var y = p2.vec2.dot(c.normalA, yAxis); if (y >= 0){ // check for jumpthrough object // check if moving upwards c.enabled = false //disable contactEquation if (f) { f.enabled = false //disable frictionEquation (solves the stuckInPlatform problem) } if (c.bodyA.velocity[1] < 15 ){ // velocity < 15 - still inside the platform c.bodyA.velocity[1] -= 5; // course correction! } } } } });The only thing that seems like it might be causing the issue would be the course correction, though I wouldn't expect that code to be executed when I am falling and land on top of a platform, since this should check if it is moving upwards on contact. If this is a common problem, please point me to the thread where I can read more about this, because I wasn't able to find it through searches. I've attached a video showing the bouncing. It's more slight in the video than usual, but sometimes it gets to the point that the character is bouncing higher than he is tall. (I apologize for the poor video quality, don't have any screen recording software installed on this computer.) IMG_1733.MOV
  8. In my code, I have a ground, and some ledges. On pressing up arrow, I want my player sprite to jump only if he is on the ground or a ledge. I added the code: if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -250; } as I saw in phaser's official first tutorial. This is working for the ground but not for the ledges. When the player is on a ledge, the up arrow doesn't make the sprite jump. In my game, I have not added them to the same group. Is that why this is happening? This is the related code: platforms = this.add.group(); platforms.enableBody=true; var ground = platforms.create(0,this.world.height - 64, 'ground'); ground.scale.setTo(2, 2); ground.body.immovable = true; ledges = this.add.group(); ledges.enableBody = true; ledges.body.immovable = true; player = this.add.sprite(32,this.world.height - 150, 'dude'); //enable physics on the player this.physics.arcade.enable(player);cursors = this.input.keyboard.createCursorKeys(); this.timer = this.game.time.events.loop(2000, this.drawLedge, this); var rand = Math.floor(Math.random() * 4500)+100; this.time2 = this.game.time.events.loop(rand,this.drawHelp,this);update: function() { this.physics.arcade.collide(player,platforms); this.physics.arcade.collide(player,ledges); player.body.velocity.x = 0; player.animations.play('right'); if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -250; } },drawLedge: function() { var ledge_y = Math.floor(Math.random()*this.game.world.height/2)+(this.game.world.height/2); var ledge = ledges.create(this.game.world.width,ledge_y,'ledge'); ledge.anchor.setTo(0.5); ledge.checkWorldBounds = true; ledge.kilOutOfBounds = true; ledge.body.velocity.x=-150; }, drawHelp: function() { var helper = ledges.create(this.game.world.width, Math.floor(Math.random()*this.game.world.height)+400,'ledge'); helper.anchor.setTo(0.5); helper.body.velocity.x = -150; helper.checkWorldBounds = true; helper.kilOutOfBounds = true; },Am I missing something?
  9. Understanding SceneOptimizer

    Need some serious guidance with SceneOptimizer. I promise I have thoroughly read through the wiki page https://github.com/BabylonJS/Babylon.js/wiki/How-to-use-SceneOptimizer-tool I believe I have included the scene optimizer javascript correctly. Not sure if I am implementing the code correctly. Basically, I'm trying to downgrade rendering on slower devices (eg Samsung Galaxy S4). Using this code below, I never see anything coming through on the console.log when testing on my Linux Debian laptop in Chrome 38. Javascript include: <script src="/libs/babylon/babylon.1.14.js"></script><script src="/libs/babylon/babylon.sceneOptimizer.js"></script>Code: var _canvas = document.getElementById("renderCanvas");var _engine = new BABYLON.Engine(_canvas, true);BABYLON.SceneLoader.Load("", "babylon/room.babylon", _engine, function (scene) { // Wait for textures and shaders to be ready scene.executeWhenReady(function () { // Optimize scene rendering BABYLON.SceneOptimizer.OptimizeAsync(scene, BABYLON.SceneOptimizerOptions.HighDegradationAllowed(), function() { console.log('FPS target reached'); }, function() { console.log('FPS target NOT reached'); } ); // ...I've tried changing out High to Low and Medium but I'm never seeing the log. Leading me to believe I'm not implementing right. Also not sure, even if I get a log from it that it is degrading. I'm unable to find any other examples from a Google search. Can someone provide a very very simple working example where it will just auto degrade whenever the frame-rate starts dropping below 30? Thank you so much. And thank you for such a brilliant library. I'll share my project when it's done.