• Content Count

  • Joined

  • Last visited

  • Days Won


Zeterain last won the day on December 5 2013

Zeterain had the most liked content!

About Zeterain

  • Rank
    Advanced Member

Profile Information

  • Gender
  • Location

Recent Profile Visitors

1180 profile views
  1. If you are trying to concatenate 'level' and the number 1, you can concatenate the number to your string like so: this.number = 1; this.game.state.start('level' + this.number); // Results in this.game.state.start('level1');
  2. If you want to pass this.number into your state, you can pass it like this: this.number = 1; var clearWorld = true; var clearCache = false; // The first 3 parameters relate to how Phaser will start the state. // All following parameters will be passed to the state's init function this.game.state.start('level', clearWorld, clearCache, this.number); In your state you can access it like this: // Assumes this function is set as the init function of the 'level' state function init(number) { // Number now holds the value of this.number that you passed in console.log(number); } (Trying for the life of me to get this syntax highlighting to work. Doesn't seem to want to cooperate. If any staff member reads this and can fix this, go for it!) Reference: https://phaser.io/docs/2.6.2/Phaser.StateManager.html#start
  3. You say that depth sorting the high-level group "doesn't solve the issue." What exactly is the issue you are experiencing?
  4. First, do you mean you are using version 2.4.7 or are you actually using 1.4.7? I am using Phaser 2.4.7 and am able to switch between states without such issues. Could you post code examples so that we can help you track the issue down?
  5. If you just copied that example code directly, the problem is that the code is activating the buttons during onInputOver events. Find the lines that contain: events.onInputOver And make sure they aren't activating the respective button's ability.
  6. I would decide how long you want it to take the score to increment, and do something like this in your update loop. You can set your timer_length to whatever you want, and the displayed score will always take that long to increment. var user_score = 9999999; // Or whatever the user scored. var display_score = 0; // Start the displayed score at 0 var timer_length = 1000; // 1 second from now. Adjust as needed. var start_time = this.game.time.time; // Save the current time var timer = start_time + timer_length; function update() { var now = this.game.time.time; // Check the timer every frame if (timer > now) { // The percentage of time that has ellapsed var score_factor = (now - start_time) / timer_length; // This should update the displayed user score. Every frame it will increment relative to how much time has ellapsed display_score = user_score * score_factor; } else { // If time is up, ensure that the display score now displays the entire score by the user display_score = user_score; } }
  7. I oppose simply in favor of time spent on Lazer. All of the options would be welcome upgrades. Pixi: I would take a Pixi upgrade for performance upgrades, but not for feature upgrades. Most likely, Support Main loop: Oppose Tilemap Renderer: Oppose Arcade physics swap: Oppose Modules: Just work on Lazer. Oppose Pool class: If this is quick, sure, otherwise, Oppose
  8. You'll want to set up a timer to see if the game is ready to fire a bullet. Here's how I'd try to do it at first: Set a timer variable, something like: this.bulletTimer = 0; Surround the code in your fireBullet function with a check to see if enough time has passed: fireBullet: function(){ // Check to see if a second or more has passed if (this.bulletTimer < this.game.time.time) { // Set the timer to now + 1000ms (1 second) this.bulletTimer = this.game.time.time + 1000; // Fire the bullet this.bullet = this.bullets.getFirstExists(false); if (this.bullet) { this.bullet.reset(this.tanque.x, this.tanque.y - 20); this.bullet.body.velocity.y = -500; } } }, This will limit the bullet to firing only once per second. You can adjust how long the timer lasts by adjusting this.game.time.time + 1000 to whatever you'd like. Just express your time in milliseconds. Let me know if this doesn't work for you.
  9. I noticed you are not enabling physics on the items. In addition to this, you are passing the entire list to be checked for overlap here: if (game.physics.arcade.overlap(sprite, list)) return true; You probably meant to index that list.
  10. I noticed that input.onUp is dispatched when the canvas event mouseout is fired. Phaser version 2.4.6. When mouseout is triggered on the canvas element, Phaser.Mouse.onMouseOut is called, which stops the mousePointer. Phaser.Pointer.stop then dispatches input.onUp. This is confusing because onUp can be dispatched even when the pointer is not actually released, but rather when the pointer simply leaves the canvas. Phaser.Pointer.Stop is also called when an active pointer leaves a touchscreen. It would make sense for onUp to be dispatched in this case because you can't tell whether the pointer was released at the edge of the screen or dragged off the screen completely. It doesn't make sense for a pointer that was never down to begin with. Thoughts? Is this an issue, or is this intentional? *Note: You can write around this strangeness without a problem. You are given the DOM event that triggered a Phaser event, so you can check to see if the event was a mouseout before taking action. I just want to make sure everything is behaving the way it should before writing around a problem. An example of a game that demonstrates this behavior. Note that the console will log the type of DOM event that triggered the onUp event. var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); function create() { game.input.onUp.add(function(pointer, event) { console.log("Up!", event.type); }); }
  11. The problem was on this line: this.game.add.sprite(0, 0, 980, 860, 'street'); You are using the sprite factory method incorrectly. The proper order of arguments can be found: http://phaser.io/docs/2.4.4/Phaser.GameObjectFactory.html#sprite
  12. Alright, so it looks like you are trying to create a state object that you want your game to use. You will need to create your game separately and add your state object to your game. Something like this: var RPG_test = RPG_test || {}, game = new Phaser.Game(640,640, Phaser.AUTO, 'game'); RPG_test.game = function (game) { this.game = game; }; RPG_test.game.prototype = { preload: function () { this.game.load.image('street', 'img/street.png', 980, 860); this.game.load.image('player', 'img/human.png', 50, 50); }, create: function () { this.game.physics.startSystem(Phaser.Physics.P2JS); this.cursors = this.game.input.keyboard.createCursorKeys(); this.game.add.sprite(0, 0, 980, 860, 'street'); this.player = this.game.add.sprite(400, 400, 'player'); this.game.world.setBounds(0, 0, 980, 860); this.game.physics.p2.enable(this.player); this.game.camera.follow(this.player); } }; // The name of the state doesn't matter too much. The last argument, true, automatically starts the new state game.state.add('RPG_test', RPG_test.game, true); Note that I didn't test this, but this should be enough to get you in the right direction. If there are any small errors like syntax issues, the console will tell you.
  13. You are overwriting your game immediately after you create it. Notice how you set RPG_test.game to an empty function right after you create your new game. RPG_test.game = new Phaser.Game(640,640, Phaser.AUTO, 'game'); RPG_test.game = function () { };
  14. The right alignment is being applied, you just aren't noticing because your text is only one line long ("hello"). Try changing your text to something with multiple lines: this.game.add.text(me.game.world.width * 0.58, me.game.world.height * 0.65, 'hello\nalign-right\nexample', { font: headingFont, fill: "#fff", align: 'right', }); You should be able to notice the right-align being applied properly.