Jump to content

Trying to get started with 1.00TS083


Yora
 Share

Recommended Posts

I'm sure there are many obvious problems that I'm blind to due to my inexperience, so I appreciate any amount of help in my pitiful efforts. :D

I'm trying to get things like velocity, tilemaps, and fill-the-screen scaling to work, though I'm running into errors with these few things(on my phone so I have no specifics atm). They also don't seem functional in the test suite, although most things in there do work. I also notice important things seem to be commented out in some of the classes, though uncommenting them didnt see me much success :P

Most of my problems seem to revolve around physics or plugins(which I'm not quite sure how to implement). I understand not everything may not be functional currently, I'm just struggling to destinguish my own (many) mistakes from what in the test suite should be working.

Link to comment
Share on other sites

Hi Yora,

 

I am coding my current game using 1.00TS083, and although I got lot's of problems (mainly due to being new to Phaser) I was able to solve most of them. If you want to give more details, maybe I can help you out. About the test suit, I believe it's not yet fully updated to the latest version of Phaser.

 

About the fill-the-screen scaling, after much struggle I got it running on my iPod touch, iPad and Android Phone. What are you doing exactly that isn't working for you ?

Link to comment
Share on other sites

Heya, thanks for the help.  ;)

 

First I'm trying to get tilemaps to work via the testsuite example, this one to be specific:

 function preload() {        //  CSV Tilemap Test        //  First we load our map data (a csv file)        game.load.text('csvtest', 'assets/maps/catastrophi_level2.csv');        //  Then we load the actual tile sheet image        game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png');            }    function create() {        //  This creates the tilemap using the csv and tile sheet we loaded.        //  We tell it use to CSV format parser. The 16x16 are the tile sizes.        //  The 4th parameter (true) tells the game world to resize itself based on the map dimensions or not.        game.add.tilemap('csvtiles', 'csvtest', Phaser.Tilemap.FORMAT_CSV, true, 16, 16);    }

which gives me the error  Uncaught TypeError: Object #<Tilemap> has no method 'preUpdate'.

 

When trying to use velocity, 

function create() {        guy = game.add.sprite(10, game.stage.centerY, 'main');    }    function update() {        guy.body.acceleration.y = 0;        if (game.input.keyboard.isDown(Phaser.Keyboard.UP) &&           !game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {            // guy.body.acceleration.y = -200;            guy.body.velocity.y -= 200;        }

which gives me Uncaught TypeError: Cannot read property 'acceleration' of undefined on any property of 'guy.body'.

 

And screen scaling I think I just figured out.  I put 

game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT;

 in the preload and put

game.stage.scale.maxWidth = window.innerWidth;game.stage.scale.maxHeight = window.innerHeight; 

in the update, and the game scales to the entire screen (at least once the window size has been changed once..)

I tried a fair share of messing around for my own solutions and actually learned from it, though I couldn't solve many of my problems in the end.  :lol:

Link to comment
Share on other sites

Didn't try tilemaps nor velocity yet. but I will let you know as soon as I do.

 

About the screen scaling, on my iPad I too the game wouldn't scale until I rotated the iPad (thus making a window size change). One solution I found is to call:

game.stage.scale.setScreenSize();

in the create() function of the main state.

Link to comment
Share on other sites

Didn't try tilemaps nor velocity yet. but I will let you know as soon as I do.

 

About the screen scaling, on my iPad I too the game wouldn't scale until I rotated the iPad (thus making a window size change). One solution I found is to call:

game.stage.scale.setScreenSize();

in the create() function of the main state.

Aah this worked, thank you :D.

 

I've been messing with tweens instead of velocity now and they've actually been preferable for me.  I love being able to link them together and make custom animations like this:

game.add.tween(bee).to({ y: pos + 50 }, delay, Phaser.Easing.Sinusoidal.Out, true, 0, false).onComplete.add(function () { game.add.tween(bee).to({ y: pos }, delay, Phaser.Easing.Quadratic.In, true, 0, false).onComplete.add(function () {
Link to comment
Share on other sites

Tweens are awesome. Btw, you can "chain" tweens using the chain() method. Your example will look like:

game.add.tween(bee).to({ y: pos + 50 }, delay, Phaser.Easing.Sinusoidal.Out, true, 0, false).chain(game.add.tween(bee).to({ y: pos }, delay, Phaser.Easing.Quadratic.In, true, 0, false)).chain(...
Link to comment
Share on other sites

re: Tilemaps - I've pushed a new version this morning which fixes that, sorry about that :)

 

re: Velocity - nope all of the physics stuff is all being dissected and ripped apart right now, please avoid for the time being in this branch specifically.

Link to comment
Share on other sites

 

Tweens are awesome. Btw, you can "chain" tweens using the chain() method. Your example will look like:

game.add.tween(bee).to({ y: pos + 50 }, delay, Phaser.Easing.Sinusoidal.Out, true, 0, false).chain(game.add.tween(bee).to({ y: pos }, delay, Phaser.Easing.Quadratic.In, true, 0, false)).chain(...

 I couldn't seem to get this to work for some reason, but either way onComplete seems to be doing the same job essentially for me if I'm not mistaken.

 

Good to hear tilemaps will be working, and at least tweens have been doing everything I wanted velocity to do so I can just continue using that for now. 

 

My next problem is trying to get state switching to work.  Typescript and Javascript are new to me so I'm not sure how I should set things up.

 

Right now I'm just working of test suite examples, so my main game is formatted like this:

/// <reference path="Phaser/Game.ts" />(function () {var game = new Phaser.Game(this, 'game', 999, 999, preload, create, update, render);function preload() {}function create() {}function update() {}function render() {}});

how would I use game.switchstate to change states?  Should I have another .ts file that follows this same format that this would switch to?  Or should I actually be formatting this differently here?

Link to comment
Share on other sites

Ah thanks, didn't see the state example before.

The next thing I'm having trouble with is when switching tabs in a browser, Tweens that were in progress act strangely upon switching back, having either stopped in place entirely or continuing ahead when it shouldn't. Is being on a different tab the same as being paused or is it handled differently?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...