Jump to content

dmko

Members
  • Content Count

    101
  • Joined

  • Last visited

Everything posted by dmko

  1. dmko

    Rotation control?

    Update - I ended up installing the `gl-matrix` lib and storing my points as `vec2` Once I had that a simple google on how to do rotation and scale with Vector2's was a piece of cake. Basically just const v1 = vec2.normalize(vec2.create(), originalVector); const v2 = vec2.normalize(vec2.create(), moveVector); const vAngle = Math.atan2(v2[1],v2[0]) - Math.atan2(v1[1],v1[0]); const vScale = vec2.length(moveVector) / vec2.length(originalVector);
  2. dmko

    Rotation control?

    Thanks!! will try that out tomorrow Wow I never saw that projection example before... man... more stuff to learn!!
  3. Whoa that is awesome - didn't realize some work has already been done I hear you about format support issues. To be clear, I'm not suggesting a standard format (though that would be awesome!) - I'm more interested in, like how I can take my own simple data and efficiently re-render everything every frame. Would it be awful to removeChild the highest node and then re-create everything? Right now I'm only thinking visually - not considering touch events and things like that. I guess if I'm going that route I might as well just break my teeth over WebGL since it would be a repaint,
  4. dmko

    Rotation control?

    Thanks! Yeah - pinning it to the corner is also a problem and tying them together via the display list is helpful I'm more stuck about the actual rotation value calculation though (and of course - it must be able to resume from whatever position it was in- not just when it starts at 0)
  5. I'm toying around with the idea of rendering out via react or some other "view-from-state" methodology. Whatever it is - in this scenario, state is managed via logic before it gets pushed to the view and state is 100% pure simple plain object data. Is there a good way to work with this and pixi? e.g. imagine I end up with objects like this (just illustrative, I haven't cracked the exact format yet): state: { background: bgTexture, spriteLayers: [ [{texture: personTexture, x:1,y:2,scale:1}, {texture: enemyTexture, x: 100,y: 100, scale: .5}], [{texture: tree, x:50,y:5
  6. dmko

    Rotation control?

    I'm porting over an old flash app that used to rely on this third-party contribution: http://proj.lamb-mei.com/handlesheet/ (you need to enable flash) Source code is at https://github.com/lamb-mei/HandleSheet It's basically just a button that you touch and move around, and it causes the target to rotate, scale, and move with it. Looks like this: Now I want to implement it from scratch in PIXI. I know I need to somehow get the rotation based on trigonometry calculations of the initial points and updated points of the button and target DisplayObject... and I'll exp
  7. I shocked me too! Programming this way is fun! Don't get me wrong - I don't think it could work for the PIXI core since there are some performance sacrifices and gc burps don't play nicely with all the immutable temp variables. But as an approach to use PIXI, it's kinda awesome imho.
  8. Here ya go Source and Notes @ https://github.com/dakom/sodium-typescript-playground Demo @ https://dakom.github.io/sodium-typescript-playground/ Explanation is in the readme and notes and some code comments... basically it's a demo for using sodiumFRP with PIXI to do functional reactive programming stuff. It's highly related to this post and this post Feedback welcome!
  9. dmko

    onRemoved from child

    hrm I'm a little worried about using a different fork... I kinda just want to `npm install pixi` and be off to the races... I hope your features make it in! Pixi 5 is a ways away though, no? it's still alpha?
  10. dmko

    onRemoved from child

    Depends on what we mean by "removed"... conceptually it could mean "removed from parent" OR "removed from scene" I agree that there should be different events for each of those
  11. dmko

    onRemoved from child

    Pixi v5 has everything I need!!!
  12. dmko

    onRemoved from child

    Yeah - that technically works in this small example, but in general is there no way for a DisplayObject to detect when it's been removed from the scene graph unless it was explicitly from a removeChild()?
  13. Is there a way to get children to do something when they've been removed indirectly? Here's a jsbin to show what I mean - only the parent notifies when its been removed, but I'd like the child to notify as well: https://jsbin.com/lolicamohi/edit?js,console,output
  14. I forgot to followup on your erase mode update... thanks for doing that btw! Is this the same answer? (will be native in v5 only)
  15. and that looking at my old code I already knew that?
  16. oh, it seems touch events can be intercepted globally - https://github.com/pixijs/pixi.js/pull/2658 ?
  17. v5?! woo! OK... so if making these changes it needs to be done manually via changing the prototype somehow?
  18. @ivan.popelyshev - is this something that's been added? i.e. to automatically wire certain PIXI primitives (e.g. Sprite) to call a top-level function (such as is done at the top of this thread, by changing the prototype?
  19. dmko

    FRP w/ PIXI?

    scratch that.... I need to do a lot more learnin! Just bought this book: https://www.manning.com/books/functional-reactive-programming highly recommended!
  20. dmko

    FRP w/ PIXI?

    Just to add - instead of like a virtual-pixi-graph thing, which is kinda crazy, maybe just pushing the commands down, so like "addSprite(texture, parent)" or a serialized version of that... So basically it'd be like this, where "viewInfo" is probably little more than the stage and some utility helper functions to test touch inputs etc. inputStream .map(input => getCommands(viewInfo, input)) .map(cmd => sendToPixi(viewInfo, cmd)) .observe(newViewInfo => updateViewInfo(newViewInfo));
  21. dmko

    FRP w/ PIXI?

    This is kindof a continuation of the discussion in this thread Though it could branch off elsewhere (like not using streams, using sodium, whatever) - so I figured I'd open a new one Basically - if one wanted to take the functional programming or functional reactive programming approach, how does PIXI fit in the picture? It seems to me like there are are basically 2 options: 1. Something like Cycle.js - where we hook the "output" of PIXI back into the inputs (also via observables/streams). 2. Have a strict unidirectional flow from input->logic/data->view.
  22. Oh wow... I'm just coming off of watching the Dr Boolean and funfunfunction stuff... and scratching my head on how to apply this to PIXI The examples here are great! Any more like this? Next up I gotta learn about Observables/streams.... seems "most" is a popular framework for that?
  23. n/m... seems InteractionManager itself will dispatch the events more reliably for some reason... I dunno why, but this approach seems to work better than just listening on the sprite itself - and it's cross-platform Maybe this base class will help others too: export class DragContainer extends PIXI.Container { private touchPoint: PIXI.Point = new PIXI.Point(); private dragOffset:PIXI.Point = new PIXI.Point(); //if listenerTarget is provided, then dragging only starts when that is touched (though this container itself is what moves) //screenLimit sets the boundries
  24. Originally, I had a Sprite which I managed to drag around by something like the following: 1. Attaching pointerdown, pointermove, pointerup, pointeroutside 2. For movement- events pass InteractionData, which allows calling getLocalPosition(parent, pointHolder, interactionData.global); 3. Simply update the position to pointHolder (there's a slight difference to my actual code where pointerdown also logs an offset which is added to the movements, and helpers/cleanup/etc. but we can ignore that for now) This worked fine - but then I noticed that really fast movements all
  25. Forgot to ping you over the weekend, sorry! Very interested if/when you make progress though
×
×
  • Create New...