• Content Count

  • Joined

  • Last visited

Everything posted by AramCP

  1. Hi, why is it wrong? My game is not in landscape mode, and mobile screens have more height than width dont they? But yes you're right, im very confused..
  2. When I started to create my game I wanted to make it look good on my own phone as a start. So I searched for my screen resolution and it is 1920*1080, so I decided to make my game 540 width and 960 height, making it the half from my res to not make the sprites too big and then scale it*2 in phaser. Yesterday I first tried it on my phone using cordova, and I can only see like 30% of my game because it is too big for the screen. And I dont really understand why is that happening.
  3. Hi, I was trying to export my game to android devices, I've never done that so I spent some hours installing all the things cordova requires and trying to figure out how everything works. After I did that I've built my cordova project and I've put all the source code in the www folder. So, when I try to run the game in browser using cordova it works perfectly with this comand: cordova run browser -- --livereload. But when I try to run it in my android device, it only displays the html parts and not the game canvas. Basically its the same thing as when you try to run a phaser game opening index.html instead of running it from localhost. I dont really know if thats something normal or if i did something wrong... So if you help me I would appreciate it a lot.
  4. In my update function I also have the player movement so putting a timer there would make my player move weird (I think). So maybe I can put that timer in the firebullet function? But i dont really know how to do that. I've searched for the Phaser 3 timer and I put this in my create function, but dont know what to do now... timedEvent = this.time.addEvent({ delay: 300, callback: onEvent, callbackScope: this});
  5. Hi, im really new to phaser3, im trying to do a space invaders game, now I was creating the bullets group, and what I wanted to do is that when you press Space, it shoots one bullet, but instead of that, when I press space it keeps creating bullets till I lift the key. This is how my code looks like: function create (){ bullets =; this.spaceKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); } function update (){ if (this.spaceKey.isDown){ firebullet(); } function firebullet(){ bullets.create(player.x, 290, 'bullet'); bullets.setVelocityY(-300); }
  6. Could you show me a little example about how to do it? I usually dont need all that help but im so confused.
  7. Maybe that will work for star the game, but for making the player movements, i think it wouldnt, because my player movements look like this right now: if(game.input.activePointer.leftButton.isDown && game.input.activePointer.position.x <= 128){ player.body.velocity.x = -velocityy;'left'); return; } if(game.input.activePointer.leftButton.isDown && game.input.activePointer.position.x >= 128){ player.body.velocity.x = velocityy;'right'); return; } else { player.animations.stop(); player.frame = 3; } As you can see i cant use game.input.onDown.add(this.movementFunction, this); Pff i dont know how im going to solve this, but thanks anyway.
  8. Hi guys, i implemented touch controls for my game, but they dont work on phones, only in computers with a mouse. Im using this: //In create function: game.input.mouse.capture = true; //And update: update: function(){ if(game.input.activePointer.leftButton.isDown){ game.state.start('game'); } }, The only thing that i wanted to do with that is start the game state when you click on the screen, and it works perfectly in my computer, but in my phone does nothing, and it should because in phaser docs it says this: A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. So guys can anyone explain me whi this isnt working? thanks.
  9. Nice, didnt thought in that, thanks man!
  10. By touching i mean that the pointer is over the sprite body yes, like in this image: Lets imagine that the red ball is the mouse poiner, so as you can see, he is above the sprite called play.
  11. Hi guys, im implementing touch controls to my game because i want to export it to android in the future, its the first time i do that and i want to know how can i make something that detects if the pointer is colliding with a sprite. I am using this for movements of the player and it works: if(game.input.activePointer.leftButton.isDown && game.input.activePointer.position.x <= 128){ player.body.velocity.x = -velocityy;'left'); return; } And the same for the right. So i want to make something like that, but instead of x position, i want to dettect if the pointer is touching a sprite, any ideas about how can i do that? thanks
  12. Thanks man it works now, btw i will check how works that browser storage.
  13. The second one is exactly what i want, but just for one session
  14. For the moment i only want to store it for one session, im not very experienced programmer and i dont really know how to implement that code you put above in my code :/, i would like to but i dont even understand what the code does, i mean i know what you want to do, but i've never used something like that before, and i preffer to dont use things that i dont know for what they're. But i apreciate the help, this will be usefull for me in the future.
  15. Hi guys i have a game where you collect money, and then a menu, where i want all your money to be shown. I have a var called money, and a var called totalmoney. And i want to store all the money that i gain playing in that variable. For example, i play the game and i collect 20 money. And then this money has to be shown on the menu screen, well thats easy, in the menu screen you create a text saying: game.add.text(128, 0, money+'$') and the money will be shown, but what if i want to play again? I cant do the same thing because the money gained will overwrite the actual money, so guys any idea about what can i do?
  16. I dont think so because dollar is inside a group, and that group is inside a function, and i call this function in the create function so all is ready to pass throught the update function. Btw i solved it, i executed it in another browser, and i've noticed that i have to put a this, before the DollarCheck(); So instead of DollarCheck(); i wrote this.DollarCheck(); And now it works. But thanks anyway mate.
  17. Hi guys, as i advanced in my game, i divided it into states, and when i enter to the game state, the browser returns me an error saying that my varibale (dollar) is not defined. The thing is all was working well before i separated it into states. Thats what i have: var dollars; var dollar; var gamestate = { DollarCheck: function() { randomx = Math.random()*208; randomy = Math.random()*170; dollar = dollars.create(randomx,-18,'dollar'); player.body.setSize(48, 28, 0, 0); game.physics.arcade.enable(dollars); }, create: function() { dollars =; DollarCheck(); }, update: function() { player.body.velocity.x = 0; dollar.body.velocity.y = velocityy; }, }; This is not all the code, just the dollar containing one, but i cant post the entire code if you want. As i said when i run it, the browser says me that dollar is undefined in line (the line where is dollar.body.velocity.y = velocityy; ). Do you see something wrong in the code guys?
  18. ofc, here is the entire code: var game = new Phaser.Game(256, 392, Phaser.AUTO, 'game', { preload: preload, create: create, update: update }); var player; var cursors; var dollars; var randomx; var randomy; function preload() { game.load.image('background', 'assets/background.png'); game.load.spritesheet('minisprite', 'assets/spritesheet.png', 48, 72); game.load.image('dollar', 'assets/dollar.png'); game.load.image('scorebar', 'assets/score.png'); } function create() { game.physics.startSystem(Phaser.Physics.ARCADE); game.add.sprite(0, 0, 'background'); game.add.sprite(0, 352, 'scorebar'); randomx = Math.random()*256; randomy = Math.random()*300 player = game.add.sprite(100, 248, 'minisprite'); game.physics.arcade.enable(player); dollars = game.add.sprite(randomx, -18, 'dollar'); game.physics.arcade.enable(dollars); player.body.collideWorldBounds=true; cursors = game.input.keyboard.createCursorKeys(); player.frame = 3; player.animations.add('left', [0, 1, 2, 1], 6, true); player.animations.add('right', [6, 5, 4, 5], 6, true); } function update() { player.body.velocity.x = 0; dollars.body.velocity.y = 60; if (cursors.left.isDown){ player.body.velocity.x = -60;'left'); return; } if (cursors.right.isDown){ player.body.velocity.x = 60;'right'); return; } else { player.animations.stop(); player.frame = 3; } }
  19. Hi guys today i started making a game and i got a problem. I want to make a game where you move to the left and to the right and items are falling from the sky, the thing is i can make one item fall in a random position, thats easy: var randomx; randomx = Math.random()*256; dollars = game.add.sprite(randomx, -18, 'dollar'); Then i set a velocity and it starts to fall, the problem comes when i want to make fall more than one sprite. I thought about something like this: var randomy; randomy = Math.random()*300; And in update function: if(dollars.position.y = randomy){ game.add.sprite(randomx, -18, 'dollar'); } With that i wanted to make a dollar fall, and when that dollar reaches a random point in the Y cordinate, another dollar will start falling, but it doesnt work, could you help me please?
  20. I think you solved my problem saying that! Im going to try it right now xD thanks!
  21. I created a state that loads all the assets, and then different states for intro, game options, maps etc... Thats not the problem, but i need to know how to pass to another map when te player colides with a specific tile, something like: if(player collides with the door){ game.state.start('nextmap') } PD: Your game looks nice but it becomes a bit laggy when you walk down
  22. Hi guys i have two maps in my game and i want to do that if my player sprite collides with a specific tile (like a door), he will enter to the other map. I created a diferent state for each map, so states are not the problem, i know how to use them, i've also exported my map, implemented it and all works well. So how can i make a player collide with a specific tile (with his ID i guees) and if he touches it then i pass to another map?
  23. AramCP

    Tiled ID issue

    Layers are okey, its just i add colision to id 23 and colides the 21, i add colision to 21 and colies 19... i dont get it
  24. AramCP

    Tiled ID issue

    I was setting the colissions for my game when something strange happened, my tile ID seems to be weird. Look at that: map.setCollision(93, true, layer3); As you can see i set collision in my tile with ID 93. I added some tiled screenshots: Well, but i enter the game and it doesnt works. maybe you think my code is wrong but its not that, look what happens when i try to walk to the left: My door tile is ID 91, and i can colide with it, while i set the colission in tile 93. Its like it moves 2 tiles to the left. Guys do yo know why is happening that? Thanks for reading.