megabyterain

Members
  • Content Count

    12
  • Joined

  • Last visited

About megabyterain

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. megabyterain

    When add sprite to two groups events.onInputDown does not work?

    Update! I realized that actually, it's the usage of the scrolling plugin that prevents the onInputDown from working. When only added to only the scroller, the buttons do not work. I guess I need to get a new plugin?
  2. Hello, everyone. I am using Phaser 2.8.3 Basically I want to add a sprite to two groups. In my game I want three columns so I have three column groups. this.leftColumn = game.add.group(); this.middleColumn = game.add.group(); this.rightColumn = game.add.group(); Later I add buttons into these groups this.spawnRateButton = []; this.spawnRateButton.push(this.leftColumn.create(0,0,"custom-left-button")); this.spawnRateButton.push(this.middleColumn.create(0,0,"custom-middle-button")); this.spawnRateButton.push(this.rightColumn.create(0,0,"custom-right-button")); for(var i=0;i<3;i++){ this.spawnRateButton[i].inputEnabled = true; this.spawnRateButton[i].events.onInputDown.add(this.buttonPress,this); } However here comes my problem. I want these columns to be scrollable, so I have to utilize this https://github.com/trueicecold/phaser-scrollable . this.scroller = game.add.existing(new ScrollableArea(x, y, width, height, {horizontalScroll: false})); //... this.scroller.addChild(this.leftColumn); this.scroller.addChild(this.middleColumn); this.scroller.addChild(this.rightColumn); this.scroller.start(); The scrolling works, however, the events.onInputDown of the spawnRateButtons do not. I click the buttons and nothing happens. When I take away the scroller everything works fine except for the scrolling, of course. When I add the sprites individually to the scroller it doesn't work either. I am guessing this is because I am trying to add the sprites to two groups? Is there a correct way to do this?
  3. The box is imported into Phaser as a single image not a spritesheet. So basically it's game.load.image("box", "path/to/image.png"); //happens in preload var box = game.add.sprite(x,y,"box"); //happens in create I looked it up, and tried the method var game = new Phaser.Game(1280, 720, Phaser.CANVAS, 'Stage', null, false, false); //the second "false" disables antialiasing but it didn't work
  4. Hello, I am creating a game with Phaser and I guess it is quite large, at least there are a lot of sprites. Using Phaser.AUTO which went to Phaser.WebGL on my desktop (i7-4770k @ 4ghz, 16gb RAM, GTX 970 4GB) I can't even maintain a 60fps (usually around 48-55fps) and there is noticeable stutter on 720p. The same is true for my 2015 Macbook Pro 15". I doubt I'd get any better results on a less powerful computer. I heard that using text with WebGL slowed it down a bunch? but that is a question for a different thread I guess. Anyway, I was searching for a way to speed up my game and came across the idea of switching from WebGL to Canvas. I did that, and on my Mac I got a solid 60fps (haven't tested on desktop yet). The only problem is that Canvas does something weird to some of my sprites (specifically ones with thin borders). I have attached two partial screenshots of my game with box sprites. As you can see, one of the box sprites is perfectly box-like, that one is running on WebGL. Once I switch over to Canvas the box sprites look like the other screenshot - lopsided. Is there a way I can fix this?
  5. megabyterain

    Multiple Phaser Timer Events?

    It's within a conditional statement, so it is only called if the state of the game is "play" as opposed to "fail". Also, the reason I did that is so the rate at which the blocks appear (along with there speed) increases as time goes on. That would not achieve my desired result of making the blocks appear faster as time goes on.
  6. megabyterain

    Multiple Phaser Timer Events?

    Hello, So I am working on my game: https://megabyterain.itch.io/firewall and it works pretty well, but I wanted to add some features to it. Mainly, I wanted to add powerups to help keep things interesting. Anyway, while I was doing so, all the sudden I noticed my code got super messed up. No console errors pop up, but my game will just stop spawning blocks after you get a power-up. In my original game, the only timer was the one that controlled when new blocks should be created. However, when I added another timer to stop the powerups (simply changing a variable back to its original state) it seems like the timer that controls the creation of new blocks stops working. Here is some sample code createPackets: function(){ //creating the square/packets... game.time.events.add(800-(this.score*1.15),function(){ this.createPackets(); //recursive function. Worked fine before },this); } //other code and stuff //on collision if(daBlock.type == "slow"){ //if the box is a slowing powerup this.speedModifier = currentSettings.powerups.slow.amount; //set speed mofifier game.time.events.add(currentSettings.powerups.slow.time, function(){ console.log("stop slow powerup"); this.speedModifier = 1; },this); } //when I remove the second timer everything works fine, but otherwise the packets/boxes/squares stop getting created after getting a powerup
  7. megabyterain

    P2 Space Shooter Dogfight AI Rotation

    That works much better; not perfect, but better. However, there is another problem. When I fly the player around the enemy the enemy will glitch and spin for a few moments. I've attached a video. I'm guessing this is because body.rotation is a value from -3.14 to 3.14 and jumps between them? How can I fix this? nimbus-record-video.webm
  8. megabyterain

    P2 Space Shooter Dogfight AI Rotation

    But then I would need to lag the hidden ship which gives me the same problem I'm having right now. point at the displacement of vector?
  9. megabyterain

    P2 Space Shooter Dogfight AI Rotation

    I'm trying to make a 2d space game involving a sort of space dogfight between the player and some ai bots. I need help with the enemy ship automatically rotating towards the player, but not being exactly pointed towards the ship 24/7. I want the enemy ship to have some "lag" in its response to the player's movement so it's more realistic. Right now I have a model which is not realistic and would probably be too hard for the player to win: update: function(){ //blah blah var tempAngle = Math.atan2(fightSprites.player.y-fightSprites.enemy[i].y, fightSprites.player.x - fightSprites.enemy[i].x); //gets angle between player and enemy fightSprites.enemy[i].body.rotation = tempAngle + (3.141/2); //too precise }
  10. megabyterain

    Get velocity of a body just before collision P2

    I was wondering this too. Did you ever figure it out?
  11. I'm making a game with a lot of asteroids. I noticed that my fps drops the more asteroids I add when running on the 2015 i7 Macbook Pro. That probably means that on less powerful laptops will lag a lot? My asteroids are similar to the ones in the game Asteroids, however I wanted them to have a somewhat realistic collision body shape that represented the sprite shape. On the Phaser p2 examples I noticed that the json for physics bodies' shapes were broken into smaller shapes like this { [1,2 , 3,4 , 5,6], //pretend that this is a triangle [7,8 , 9,10 , 11,12], //pretend this makes another triangle [13,14 , 15,16 , 17,18] //pretend this makes another triangle } //pretend if you put all of the those shapes together it would make another shape as opposed to just having it as one complex shape like { [1,2 , 3,4 , 5,6 , 7,8 , 9,10 , 11,12 , 13,14 , 15,16 , 17,18] //pretend this makes a shape } Which is better for performance? Also I want to have maybe around 200 asteroids in my game at a time, not to mention some other bodies as well. Should I reduce the amount of vertices of the asteroid's collision bodies? Would setting it to be a circle be less power demanding? The game works fine on my desktop, but that has a gtx 970 and I doubt most people who play my game will have that sort of power.
  12. Ok, so I'm trying to set up an inventory system for a game of mine in Phaser 2.5.0 and there doesn't seem to be a way to have a scrollable view in for my inventory. I'm trying to make an inventory similar to that of Fallout's where part of the screen scrolls through the items, while the other part shows the item's description and picture (no fullscreen scroll please). Has someone found a work around to this? If I can't use a scroll view would the next best thing be a multi-page inventory? Maybe a grid based one? Any ideas? Thanks!