jmp909

Members
  • Content Count

    432
  • Joined

  • Last visited

  • Days Won

    4

Reputation Activity

  1. Like
    jmp909 got a reaction from microspace in Scaling a map without affecting the placement of a sprite   
    I had assumed you might not want to scale the sprites, but you appear to have fixed what you need
     
    I had made this anyway as a rough test in that case
    http://phaser.io/sandbox/GKTRPIOi/play
     
    W,A,S,D and NumPad +/- to scale
     
    I should probably have used the camera though instead of shifting the map
  2. Thanks
    jmp909 got a reaction from dude78 in Child sprite anchor - strange behaviour   
    fixed by creating a new angleToPointer version that uses sprite.world.x  rather than sprite.x  in its calculations (since our sprite is nested we need the global coords)
    http://phaser.io/sandbox/UuTkxwqm/play
  3. Like
    jmp909 got a reaction from eidosk in Masking a sprite with a complex shaped image   
    Ok, good challenge for me, as I was doing some of this the other day
     
    i create a bitmap from the player and set its non-transparent pixels to a solid colour (sillhouette) i create a bitmap the size of that bitmap and fill it with a colour (fill) i create an extra bitmap to do the alphamasking on....masking the fill with the sillhouette, and shifting the fill accordingly to do a 'bucket fill' percentage i create a sprtite to show the masked bitmapdata  
    http://phaser.io/sandbox/rWIJwRJF/play
     
    I'm trying to think if there's a simpler solution
  4. Like
    jmp909 got a reaction from samme in Masking a sprite with a complex shaped image   
    Ok, good challenge for me, as I was doing some of this the other day
     
    i create a bitmap from the player and set its non-transparent pixels to a solid colour (sillhouette) i create a bitmap the size of that bitmap and fill it with a colour (fill) i create an extra bitmap to do the alphamasking on....masking the fill with the sillhouette, and shifting the fill accordingly to do a 'bucket fill' percentage i create a sprtite to show the masked bitmapdata  
    http://phaser.io/sandbox/rWIJwRJF/play
     
    I'm trying to think if there's a simpler solution
  5. Like
    jmp909 got a reaction from DeadStar66 in Phaser Isometric - Move player to tile onclick?   
    i've put a demo here
    http://jsfiddle.net/arakfyzd/2/
  6. Like
    jmp909 got a reaction from Nicholls in Child sprite anchor - strange behaviour   
    fixed by creating a new angleToPointer version that uses sprite.world.x  rather than sprite.x  in its calculations (since our sprite is nested we need the global coords)
    http://phaser.io/sandbox/UuTkxwqm/play
  7. Like
    jmp909 got a reaction from indextwo in Tile Sprite   
    with a normal sprite if you changed smoothed value you can do this
    background.smoothed=!background.smoothedbackground.texture.baseTexture.dirty() // not a public API function there might be an equivalent for tileSprite
  8. Like
    jmp909 got a reaction from juandelossantos in animated tilemap   
    actually I think this is what you're looking for (although it looks slightly broken)
    http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=create+from+objects.js&t=create%20from%20objects
  9. Like
    jmp909 got a reaction from pyre in caching graphics to RenderTexture or BitmapData and adding to cache   
    this seemed to work.. is it the correct approach? 
    var sprite = this.game.add.sprite(0,0,this.game.cache.getRenderTexture('starRT').texture); j
  10. Like
    jmp909 got a reaction from chipnin in Add bitmapdata to cache as image   
    there's also an option I detail here if you need something that has to be pulled from the Image cache using a string key (specifically RetroFont in this case) : http://www.html5gamedevs.com/topic/17436-image-creation-and-cache/?p=99066
     
    convert the bitmap data to a dataURI with myBitmapData.generateTexture("key") which automatically adds the image to the Image cache with that key
     
    this is explained here
    http://phaser.io/docs/2.3/Phaser.BitmapData.html#generateTexture
     
    Rich's example won't work in that case because RetroFont won't pull it's key from the BitmapData cache.
    (it's not relevant to your actual case but it's relevant to your subject line, so I thought I'd add it here for anyone coming here for that reason)
  11. Like
    jmp909 got a reaction from lewster32 in How Drag sprite around circle   
    in fact, since you're request was actually to drag the sprite, I've made a version where you need to actually hold the mouse down on it to move it
    http://phaser.io/sandbox/hftdIYxX/play
     
    the only improvement I'd like to make, but am not currently sure about, is to only move the sprite when the pointer is actually over it.
     
    j
  12. Like
    jmp909 got a reaction from samme in How Drag sprite around circle   
    here's one way to do it using Sin/Cos
    http://phaser.io/sandbox/gXbgAMnK/play
     
    and another using phaser's point rotation function (with a distance constraint... http://phaser.io/docs/2.4.4/Phaser.Point.html#rotate)
    http://phaser.io/sandbox/wDpGcNHm/play
     
    I've taken 0 angle as the top of the circle, but that's not the normal way angles are measured so i've shifted the value accordingly
     
     
    I'll leave you a challenge... add acceleration/deceleration to the movement....
  13. Like
    jmp909 got a reaction from Nitay in Creating a mini map from a render texture?   
    I'd be interested in advice on this too
     
    if you go here..
    http://phaser.io/examples/v2/tilemaps/csv-map-with-p2
     
    and paste in this code..
    http://pastebin.com/RK2rs527
     
    you'll see i've done a rough example of a mini map 
     
    however I'm not sure this seems like a good idea:
    w = layer.widthh = layer.heightm = new Matrix() // not used currently    // temporarily crop map layer for renderlayer.setFrame({x:Math.max(0,player.x-game.camera.x)-200,y:Math.max(0,player.y-game.camera.y)-200,width:400,height:400})renderTexture.render(layer, m, true)// reset layer to original dimensions (otherwise the map remains cropped)layer.setFrame({x:0, y:0, width:w, height:h}) it works but it doesn't seem like you should crop & reset it. it would be good if render()took a rectangle as an argument for the source, but I think that's from the PIXI library.
     
    anybody have any suggestions?
     
    thanks
    j
     
  14. Like
    jmp909 got a reaction from Sanju in Phaser Isometric plugin   
    for TypeScript, if you don't want to edit source, you can also bypass errors using bracketed property notation, rather than dot syntax
     
    this should work.. 
    isoPlugin['arcade'] = new Phaser.Plugin.Isometric.Arcade(this.game) 
  15. Like
    jmp909 got a reaction from strivinglife in How does one use Plugins in TypeScript?   
    Hi,
     
    I've just got this working for this plugin at least https://github.com/aaccurso/phaser-state-transition-plugin
     
    looking at the required methods for it, I created a .d.ts file for it and added it to my project
    /// <reference path="/typings/phaser/phaser.d.ts" />// definition for https://github.com/aaccurso/phaser-state-transition-plugindeclare module Phaser { module Plugin { class StateTransition extends Phaser.Plugin { constructor(game:Phaser.Game, parent: any); // not sure what parent type is configure(options:Object):any; // to(key) // to(key, clearWorld, clearCache, parameter) to(key:string, clearWorld?:boolean, clearCache?:boolean, parameter?:Object):void; } }} I can now call this in my project like this
    // note the < > type-castingvar st = <Phaser.Plugin.StateTransition> this.game.plugins.add(Phaser.Plugin.StateTransition);st.configure({ //how long the animation should take duration: 1000, //ease property ease: Phaser.Easing.Exponential.InOut, // default ease //what property should be tweened properties: { alpha: 0, scale: { x: 1.5, y: 1.5 } }}); st.to("GameRunningState"); hope this is of use to someone
     
    thanks
    j
  16. Like
    jmp909 got a reaction from Sanju in Question about creating and loading Phaser Plugins with Typescript.   
    that code should work I think, but see my answer here
    http://www.html5gamedevs.com/topic/10016-how-does-one-use-plugins-in-typescript/?p=97735
     
    i've had to create a .d.ts file for any plugin i use, mapping its functions. 
     
    eg for the ScreenShake plugin (https://github.com/dmaslov/phaser-screen-shake) the following to be sufficient for getting it to compile ok in Visual Studio Code. (I'm new to this so I'm not claiming it to be perfect, but it works to get it up and running)
    declare module Phaser { module Plugin { export class ScreenShake extends Phaser.Plugin { constructor(game:Phaser.Game, parent:any); // not sure what "parent" type should be.. can anybody help here? setup(obj:Object):void; shake(count:number):void; } }} then in my code I call
    var ss = <Phaser.Plugin.ScreenShake> this.game.plugins.add(Phaser.Plugin.ScreenShake);ss.shake(10); note the need for type casting from Phaser.Plugin to Phaser.Plugin.ScreenShake
     
    hope this helps
    J.
  17. Like
    jmp909 got a reaction from MichelAlonso in How does one use Plugins in TypeScript?   
    Hi,
     
    I've just got this working for this plugin at least https://github.com/aaccurso/phaser-state-transition-plugin
     
    looking at the required methods for it, I created a .d.ts file for it and added it to my project
    /// <reference path="/typings/phaser/phaser.d.ts" />// definition for https://github.com/aaccurso/phaser-state-transition-plugindeclare module Phaser { module Plugin { class StateTransition extends Phaser.Plugin { constructor(game:Phaser.Game, parent: any); // not sure what parent type is configure(options:Object):any; // to(key) // to(key, clearWorld, clearCache, parameter) to(key:string, clearWorld?:boolean, clearCache?:boolean, parameter?:Object):void; } }} I can now call this in my project like this
    // note the < > type-castingvar st = <Phaser.Plugin.StateTransition> this.game.plugins.add(Phaser.Plugin.StateTransition);st.configure({ //how long the animation should take duration: 1000, //ease property ease: Phaser.Easing.Exponential.InOut, // default ease //what property should be tweened properties: { alpha: 0, scale: { x: 1.5, y: 1.5 } }}); st.to("GameRunningState"); hope this is of use to someone
     
    thanks
    j
  18. Like
    jmp909 got a reaction from Stucky in Phaser Multiple layers not rendering in screen with Tiled json map data   
    1) as I have already mentioned you can't createLayer on an object layer . That one will give you the null ID error
    2) if you're saying foreground tile layer is giving you an error , try CSV encoding instead of base64 (but still export as json) and see if that works
  19. Like
    jmp909 got a reaction from drhayes in How Drag sprite around circle   
    I always forget my trigonometry, so I'm glad to accept this challenge... this should get you started
    http://phaser.io/sandbox/CpErwgAd/play
  20. Like
    jmp909 got a reaction from san40511 in How Drag sprite around circle   
    I always forget my trigonometry, so I'm glad to accept this challenge... this should get you started
    http://phaser.io/sandbox/CpErwgAd/play
  21. Like
    jmp909 got a reaction from san40511 in How Drag sprite around circle   
    in fact, since you're request was actually to drag the sprite, I've made a version where you need to actually hold the mouse down on it to move it
    http://phaser.io/sandbox/hftdIYxX/play
     
    the only improvement I'd like to make, but am not currently sure about, is to only move the sprite when the pointer is actually over it.
     
    j
  22. Like
    jmp909 got a reaction from pablotebb in Using partially transparent images as brushes on bitmapData   
    I'm guessing it's related to this
    http://www.html5gamedevs.com/topic/17676-double-buffered-rendertexture-trail-never-reaches-0-alpha/
  23. Like
    jmp909 got a reaction from jilonor in event listeners on sprites with limited context   
    Thats wrong
    this.selectorGroup.alpha = 0;
     
    that would just set the group alpha to 0, not the children's alpha
     
    either use setAll or forEach
  24. Like
    jmp909 got a reaction from Cryptonomicon in Have Empty Sprites Changed?   
    Use skipRender
    https://github.com/photonstorm/phaser/issues/2173
    https://github.com/photonstorm/phaser/issues/2176
  25. Like
    jmp909 got a reaction from WombatTurkey in Phaser Isometric - Move player to tile onclick?   
    i've put a demo here
    http://jsfiddle.net/arakfyzd/2/