Bizzi Posted July 5, 2013 Share Posted July 5, 2013 Hey Yesterday i have found Phase, REALLY REALLY GREAT! Its really easy I have a Problem:On the examples is a TiledMap and a ScrolingCamera example...How i combine that?Problem is:The "Player" will only following on the Map on the TileSet Example. If i going to the end of map, the player will be hidden. That problem is on the Scrolling Map example not.i hope you dont understand me, im not really speak perfect english.Were is the Documentation about Phaser - Not found that. Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 There is a command: Camera.follow that allows the camera to follow a Sprite. So as it moves around the map the camera will follow it. The camera has a bounds value. This is what is used to control how far it can move around the world. If the camera bounds is smaller than the world size then the camera would stop moving even though the world or sprites may carry on. Have a look at World.setSize() and camera bounds to make sure they are both the same size. Documentation is coming in the 1.0 release, I promise Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 Thanks for your answer Hmm, its not that wat i need.On the ScrollingZone, the "Player" are centered, the Map will be moved if the player moving. The Scrolling zone is endless.I need the Tilemap with the feature by scrolling zone - endless and the player are always centered.i have try to experimented with the camera options inter alia with the following method/function. but I do not get the desired result.Before i used Phaser, i have created an example only in Javascript, checkthis out: http://k-fuckz.net/subs/flight/ Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 Tilemaps can't be endless right now. Technically what you need (I assume?) is for a tilemap to wrap at the edges, as by its nature a tilemap couldn't really be endless. I couldn't make the plane move in your example btw. Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 The moving on the example was not implemented yet.Yes i know - Tilemaps cant be endless. but it is not possible to combine both? i mean,..the tilemap will be moved regardless of whether the player goes over it?Can you following me?EDIT:I have an idea. I copy with the tilemap and make an additional plugin. then I change the functions and take the place out, where it is said "not scroll further." Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 Set your player sprite to have a scrollFactor of 0,0 so it doesn't get influenced by the camera and position it in the middle of the screen. Then just move the camera around the world rather than trying to move the map itself. The player will stay fixed in the middle then regardless (as long as you don't collide it with the map). Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 Have you a little example?Without docu its really heavy.Edit:i have try to set the scrollFactor, problem: not working.I have try it to set it for camera, map, sprites,.. the method not exists, the console says that the variable/function is undefined. Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 Look at the Camera Bounds test code, that shows you how to move a camera around using the arrow keys. If you had a tilemap in the world it would move the camera around the map. Then just put a sprite in the game and do: sprite.scrollFactor.setTo(0, 0);and watch what happens. Bizzi 1 Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 this.airplane = this.game.createSprite(this.game.stage.centerX, this.game.stage.centerY, 'airplane');this.airplane.scrollFactor.setTo(0, 0);Same issue:Uncaught TypeError: Cannot call methid 'setTo' of undefined Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 Which version of Phaser are you using? That is how you'd do it for the current master branch (0.95). Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 latest version. i have found the problem. i have write "scollin" and not "scrolling" i try my version to modify a copied version of tilemap - its solve not my problem.How i can call to the game "please render" if the window are resized? Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 I don't really understand what the problem is to be honest. scrollFactor is a valid sprite property in 0.95, so it must be something else in the code elsewhere causing it to be wrong. How i can call to the game "please render" if the window are resized? ? Link to comment Share on other sites More sharing options...
Bizzi Posted July 5, 2013 Author Share Posted July 5, 2013 Ok, a little bit simplier: i have created a TiledMap object.Default is: If the player moves, the map will be following.What i search is:The Player Spirte will be centered on the Game - These only rotating.The Map will move and not the player. Example:function render() {// Keyboard...var speed = 200;var motion = this.game.motion.velocityFromAngle(this.airplane.angle, speed);// EXAMPLEthis.map.setPositionTo(motion);}For the "resizing":If you resize your window, the game not update that.Can i update the size after "setup"?Example:window.onresize = function() {// Update game size,...MyGame.setSize(window.innerWidth, window.outerWidth);}; Link to comment Share on other sites More sharing options...
PixelPicoSean Posted July 5, 2013 Share Posted July 5, 2013 Tilemaps can't be endless right now. Technically what you need (I assume?) is for a tilemap to wrap at the edges, as by its nature a tilemap couldn't really be endless. There is a concept from impact.js that you can specify a small tilemap to be repeated (like the tiled wall paper) which provide an "endless tilemap". I guess that's what Bizzi want, or something like that. Actually I have no idea of how this be useful, maybe for some special art style? Bizzi 1 Link to comment Share on other sites More sharing options...
rich Posted July 5, 2013 Share Posted July 5, 2013 Ok, you can't apply a velocity to a tilemap. What you need to do is move the camera, not the map. If the sprite has a scrollFactor of 0 it will remain fixed in place. As for the window resizing this is handled much better in 1.0 but you can apply css to the canvas to get it to scale to a % size, then it will match the browser window as it changes. Bizzi 1 Link to comment Share on other sites More sharing options...
Bizzi Posted July 6, 2013 Author Share Posted July 6, 2013 About the resizzing:I have read that there methods are implemented to a non-stable (0.97)?i have try to use 0.97 - ich check for afternoon the source for the methods. yesterday i have setup my project for 0.97.And yes, PixelPicoSean, that is it! a "endless" tiledmap.My ideas for them: A Gorund like ScrollZone there scrolling endless, and above the Tiledmap. On the tiled map can use collisions to say to the player "here is the map end"... Link to comment Share on other sites More sharing options...
Recommended Posts