Jump to content

Search the Community

Showing results for tags 'sprite rotation angle'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hi again, I have a rectangle that orbits around a player, and I'm attempting to get it to always have the same side facing inwards. This is actually called "tidal locking", and is what happened to our moon: the same side of the moon always faces the Earth. This is because the time that it takes for the moon (rectangle) to rotate on it's axis is the same time that it takes to revolve around the earth (player). This is what I'm trying to mimic. So if my rectangle has one long red side and one long blue side, I always want the blue side facing in towards the player. I was attempting to do this by causing the rectangle to rotate on its axis, but i'm not clever enough to determine what the angle of rotation should be in order to match the rotational speed. Does anyone have the math wits about them to help me solve this, OR another possible solution to the problem (other than not doing it, lol)? Create() rectangles = game.add.group(); // Player sprite is 64x76, so add half of each to top-left // corner to find center. var pCenterX = player.x + 32; var pCenterY = player.y + 38; // Create rectangle at the center of the player. // Rectangle is 40x20 in size. var rectangle = rectangles.create(pCenterX, pCenterY, 'rectangle'); rectangle.anchor.setTo(0.5, 0.5); // orbitPoint is the point at which orbit occurs. orbitPoint = new Phaser.Point(pCenterX + 50, pCenterY + 50); // orbitTarget is the point at which orbitPoint orbits around. orbitTarget = new Phaser.Point(pCenterX, pCenterY); Update() rectangles.forEachAlive(function(rectangle) { // Start orbit. orbitPoint.rotate(orbitTarget.x, orbitTarget.y, game.math.wrapAngle(d), true); // Since rectangle is a sprite and not a Phaser.Point, not sure how // to orbit the sprite other than to have the rectangle sprite follow // the orbitPoint's coordinates. rectangle.x = orbitPoint.x; rectangle.y = orbitPoint.y; // Angle for rotation...trying to get this to face // player center (not sure how to do it) rectangle.angle += 1; // Angle d += 5; });
×
×
  • Create New...