Ppozniak

Members
  • Content count

    5
  • Joined

  • Last visited

About Ppozniak

  • Rank
    Newbie
  • Birthday 05/17/1995

Contact Methods

  • Website URL
    http://ppozniak.pl
  • Twitter
    ppozniak95

Profile Information

  • Gender
    Male
  • Location
    Poland, Szczecin
  • Interests
    coding, heavy music and coding.
    Oh and also I like meat

Recent Profile Visitors

277 profile views
  1. Holy sheet. It was like my experience... I was creating a game and decided to stop, just to see if it's so easy to push it into real working .apk thing and play it on mobile like real application! Yay! A while of reading through the internet - Cocoon is giving performance, great thing "canvas+" and it's great and it's easy!!!11 Who doesn't like performance and "easy". Looking at the docs... there is almost nothing there? What the ****, do you just need to upload your files and press one button? That's all? Not possible. I've tried doing it with their Cocoon Developer App for Android, the package was 200mb large, but let's give it a try. The app gave me uncompressing error - I've created a topic on their forums https://forums.cocoon.io/t/cocoon-developer-app-uncompressing-error/5765 but no one answered. Not great start. Oh maybe this app is broken, let's compile it in normal way. But it seems I was trying to install .apk without -debug affix and my phone said "Installation not done"... Yesterday I've downloaded Unity one more time, I said yeah let's **** it it will be easier on Unity. However as a front-end developer I am really in love with JS and after spending a couple of hours with Unity I've felt JavaScript is calling me, and Unity is boring. So I said - hey, I am not giving up! Will try with Cordova itself. Couple of hours, installing requirements finally my first test app. Let's run that awesome "cordova build android" - DONE. But what now? I cannot see .apk. Looking at /platform/android and wondering where the heck is my .apk or if it's even there. Instead of searching the directory I've asked google first for some reason. And there it was - /platform/android/build/apk - Sent it to my mobile phone, installed. And that little moment - it works. Feels great. Now reading this I've used -debug.apk from Cocoon (normal compilation) and guess what - Cocoon logo shows and then the black screen. Will probably give Cocoon another try because it seems great, however not sure why it's not working. For now I'll go with Cordova and see how it goes. EDIT: You probably need to use PHASER.CANVAS not AUTO or WEBGL with Cocoon's Canvas+ (obviously). At least that was the issue in my case, yey! Yeah I know no one cares, but this article was so true that I had to share with you, good to know you're not alone with those kind of problems. I guess sometimes it also lies on the documentation side, while it's not good enough or clear enough. Best regards.
  2. @ncil that's because platforms is a group, which has another groups inside (platform). And in documentation you can find (collide method) https://photonstorm.github.io/phaser-ce/Phaser.Physics.Arcade.html#collide: Velocity on blocks makes an illusion of that the only player is moving, but I don't want the player to only stand and jump so he can move around (like he was slowing down or running faster in real life, but he is always running). Could've done with camera, and stage, but can be also done this way. @samme thanks for the tip. Unfortunately it still doesn't work as intended, however it happens much less often and not so "hard". Seems that removing collision from inner blocks has speed up the game significantly. My theory is that some blocks move faster than others and that's why it creates really tiny floor, because when I was debugging that before touching.right and touching.down were true, while player was on side of a wall. I am not sure about your last point Use a single physics body for each platform. What do you mean by that? You cannot apply physics to group, so I'm kinda confused. Or maybe there is a way to create body? So tiles would be tiles, but then I would apply one big "fake" body that would cover all of the blocks? If that's what you meant I am not quite sure how to achieve that. #Edit I've tried making an empty sprite, then apply body to that and make it as long as the tiles, same with height and it's working pretty good! Never thought of making empty sprite, which is kind of silly in terms of logic I guess? However thanks for the help! Best regards. Like this
  3. Thanks for your reply @ncil I have a simple .collide method, nothing else applied at the moment: this.game.physics.arcade.collide(this.player, this.platforms.children); While platforms is another group that has platform instances inside import Platform from './Platform'; export default class Platforms extends Phaser.Group { constructor(game) { super(game); this.game.add.existing(this); this.game.global.spawnPlatform = new Phaser.Signal(); this.game.global.spawnPlatform.add(this._spawnPlatform, this); this._init(); } // Create initial ground _init() { this.add(new Platform(this.game, { width: this.game.width * .5 })); } // Spawns platform _spawnPlatform(prevRight = 0) { const RAND_Y = this.game.rnd.integerInRange(200, 400), GAP = this.game.rnd.integerInRange(0, 200), RAND_WIDTH = this.game.rnd.integerInRange(150, 700); this.add(new Platform(this.game, { startX: prevRight + GAP, startY: this.game.height - RAND_Y, width: RAND_WIDTH, })); } } Just adding this in case this matters. Hope that makes sense. Best regards.
  4. Hello there. I am dealing for a long time with this issue. I am making an endless runner where platforms are made from small chunks (each 32x32 square). Character should fall down, not stop on the wall. This also happens when chunks don't have any velocity, until I add if( this.body.touching.right ) { this.body.velocity.x = 0; this.body.acceleration.x = 0; } to the player sprite. When I don't apply velocity to the chunks but instead say this.left -= 10 on chunk group in update the things are get more weird I guess that has to do something with chunks, am I doing this in wrong way? Each platform is a group, to which I add those chunks export default class Platform extends Phaser.Group { constructor(game, _) { super(game); const defaults = { startX: 0, startY: game.height - 64, width: game.width * .3, tileLevel: 1, tileFrame: 8, }; this.state = { extended: false }; _ = Object.assign({}, defaults, _); this.physicsBodyType = Phaser.Physics.ARCADE; this.enableBody = true; // Y axis for(let y = _.startY; y <= game.height + game.global.tileSize; y += game.global.tileSize) { // X axis _.tileLevel === 1 ? _.tileFrame = 8 : _.tileFrame = 1; for( let x = 0; x < _.width; x += game.global.tileSize ) { this.create(x + _.startX, y, 'tileset', _.tileFrame); } _.tileLevel++; } const BODY_OFFSET = 4; this.forEach((child) => { child.body.immovable = true; child.body.allowGravity = false; child.body.offset.y = BODY_OFFSET; child.body.friction.set(0); child.body.velocity.x = -10; }, this); } update() { // Spawn another platform if ((this.left <= this.game.width) && (!this.state.extended)) { this.state.extended = true; this.game.global.spawnPlatform.dispatch(this.right); } // Destroy when off bounds if(this.right < 0) { this.destroy(); } } } Best regards.
  5. Endless runner - object pool

    Hello there. For my first Phaser game I want to create an endless runner. I want to be sure right from the start that everything I'm doing is done in the best possible way. I know there might be no straight / easy solutions, but I want to know your opinion, as my experience with Phaser is rather short (1 week). 1. Idea I'm having one big Phaser.Group called Platforms, which is called right in the main game and that group handles everything when it comes to the groups. Inside of Platforms you can spawn platform which is also a group. And that group (platform) has many instances of Ground, which is extension of the Phaser.Sprite // ground.js class Ground extends Phaser.Sprite { constructor(game, x, y, frame) { super(game, x, y, 'tileset', frame); const BODY_OFFSET = 3; this.game.physics.arcade.enable(this); this.anchor.setTo(0, 1); this.body.immovable = true; this.body.allowGravity = false; this.body.offset.y = BODY_OFFSET; this.body.height -= BODY_OFFSET; this.body.velocity.x = -this.game.global.speed; this.body.friction.x = 0; } } export default Ground; // platform.js import Ground from './ground'; class Platform extends Phaser.Group { constructor(game, { startX = 0, startY = game.height, width = game.width } = {}) { super(game, startX); this.settings = { startX, startY, width }; this.flags = { extended: false }; // Platform building loop // 1. Prepare variables let tileLevel = 1, tileFrame = 8; // Y axis for(let y = startY; y <= this.game.height + this.game.global.tileSize; y += this.game.global.tileSize) { // X axis tileLevel === 1 ? tileFrame = 8 : tileFrame = 1; for(let x = 0; x < width; x += this.game.global.tileSize ) { this.add(new Ground(this.game, x, y, tileFrame)); } tileLevel++; } } update() { // When off bounds - spawn another platform if ((this.centerX < this.game.width) && (!this.flags.extended)) { this.flags.extended = true; this.game.global.spawnPlatform.dispatch(this.right); } if(this.right < 0) { this.destroy(); } } } export default Platform; Every little piece of ground has the same velocity and settings. Player collision is checked based on platforms.children. For now I'm destroying platform when it goes off screen and calling global spawnPlatform function when middle of a platform is on the left border of the screen (to spawn it a little earlier). And here come my questions and ideas: 2. Ideas & questions Recently I've learned about Object pools. My platforms were done by doing some random numbers (width, height etc) but I've noticed that even with one platform performance goes dramatically down. I mean maybe not dramatically, but it's not a good sign. There was that "sawtooth" pattern on the memory section (DevTools). Here are my ideas: 2.1 Leave it as it is Platform spawns, platform goes off the screen, platform gets destroyed. 2.2 Generate many random platforms at the beginning, and then just re-use them At the beginning game would generate a big array of defined platforms, that would still be much-less random. When the platform goes off the screen it's not destroyed. Instead it's killed. But here comes my problem - you can't kill groups. Only sprites inside (Ground instances) could've been killed. But will it be really a better solution? Killing every ground, moving the platform out of 'living' array, and then when platform gets spawned revive them? 2.3 Generate object pool of Ground instances and use them as 'blocks' for platforms I think that's pretty much the same as 2.2, but maybe a little bit different. Creating big arrays of different types of blocks, and then using them to build platforms. I think like max 5 platforms will be visible at one moment on the screen so I wouldn't have to create many blocks. Platform goes off - Ground(s) get killed, group destroyed (?) Also before I end - on the screenshot you can see that sometimes the connections between tiles are visible. I don't think that's the spritesheet case. Maybe something with small delays between creating each platform? Not quite sure. Any ideas? Another problem lies in gaps between each platform. I guess that's caused by a delay between creating a platform and spawning it. I want to ensure I'm doing everything right from the beginning, so pardon me if I sound stupid or that's just silly question. Hopefully someone will be able to answer my question and help me out. Thanks for creating Phaser. Making games have always been my dream, but recently I was focused on the front-end development. Now I can combine those two