# kozy

Members

13

• Rank
Member

• Gender
Not Telling

## Contact Methods

@quichardwrigley
1. ## change zero point of sprite rotation

Solved here! http://www.html5gamedevs.com/topic/14489-change-zero-point-of-sprite-rotation/
2. ## change zero point of sprite rotation

I figured it out! Only took a month or two of free time! And stackoverflow! Here's the crux of the code: if (Math.abs(degs - prevAngle) > 180) { //find out if target angle (degs) is < or > 180* var turnSide = findTurnSide(prevAngle, degs); //find which way to turn var shortAngle = getDifference(prevAngle,degs)*turnSide; //get the shortest angle between prev and targ points on a circle and multiply by turnside (+ or -) var newTargetAngle = prevAngle + shortAngle; //calc new target angle steps[i].degs = newTargetAngle; //set angle in array for chained tween}before this code I am pushing an x and y and an angle to rotate to (degs) into steps - the x and y come from a pathfinding route array, which I can calculate the angle to the next tile to get degs. Hope this helps someone!
3. ## change zero point of sprite rotation

I started a topic in both phaser and pixi forums.. won't do that again! http://www.html5gamedevs.com/topic/14489-change-zero-point-of-sprite-rotation/#entry82422
4. ## change zero point of sprite rotation

My chainedTween is set in the for loop but the "angle: degs" rotates to degree, not /by/ degree. So I'm trying to figure out how to set my chainedTween where I can actually use "sprite.angle += turnRate" to change the heading of the sprite on the fly I'm pretty sure I need to set a Timeout for each iteration in the loop so the tween can run inside the loop while it appears on the canvas. This will give the chainedTween.onUpdateCallback access to those variables inside the loop var chainedTween = game.add.tween(sprite); var animationTime = 500; //higher = slower var sourceAngle = sprite.angle; var targetAngle; var degs; var turnRate; //attach for (var i = 1; i < steps.length; i++) { //skip first starting tile sourceAngle = steps[i].degs; targetAngle = ((i < steps.length - 1) ? steps[i + 1].degs : sourceAngle); degs = turnByDegs(sourceAngle, targetAngle); chainedTween.to({ x: steps[i].x, y: steps[i].y, //angle: degs }, animationTime, Phaser.Easing.Linear.None); turnRate = degs/animationTime; } chainedTween.onUpdateCallback(function () { console.log("update"); sprite.angle += turnRate; });chainedTween.start();
5. ## change zero point of sprite rotation

My problem is that I'm trying to rotate a sprite from one angle to the next without generating obtuse angles based on the sprite's current angle (i.e. from 180* to -270*). This causes giant rotations sometimes when my sprite moves from one tile to the next, though just in one quadrant of the 2d plane, I've found. Having the sprite's rotation reset to 0 when the sprite stops would fix this I think, as the angle I generate to the next direction would be much less. I'm experimenting with adding http://greensock.com/DirectionalRotationPlugin to my onUpdateCallback function and might be getting somewhere..
6. ## change zero point of sprite rotation

Is it possible to change the default 0 point of a sprite's rotation? So when a sprite rotates to say 135*, 135* becomes the new 0 point? Help is greatly appreciated!
7. ## change zero point of sprite rotation

Is it possible to change the default 0 point of a sprite's rotation? So when a sprite rotates to say 135*, 135* becomes the new 0 point? Help is greatly appreciated!
8. ## The Phaser 3 Wishlist Thread :)

one more suggestion on pathfinding: something similar to this for polygonal pathfinding / map building https://github.com/gmac/constellation.js
9. ## AStar.js Pathfinding Bug

This is what's working for me! https://github.com/appsbu-de/phaser_plugin_pathfinding
10. ## get cache json layers / data?

answered my own question: theWorld = game.cache.getTilemapData('desert').data.layers[0].data;
11. ## get cache json layers / data?

I'm trying to figure out how to get json layer data from the phaser cache.. I'm using game.cache._json but this just seems to return functions? I'm trying to get tile data so I can create 2d array of tile types (e.g. 0,0,8,5) each value representing a tile from the tilemap. I'll then use this with A* for pathfinding. Any help would be appreciated! -Rich
12. ## The Phaser 3 Wishlist Thread :)

Really would like native pathfinding for tilemaps. All kinds of pathfinding would be awesome too! A-Star apparently hasn't been working with newer versions of Phaser http://www.html5gamedevs.com/topic/11483-astarjs-pathfinding-bug/
13. ## AStar.js Pathfinding Bug

Any update on this? A-star is perfect for what I'm trying to do! Thx!