Jump to content

Search the Community

Showing results for tags 'box2d rube'.

  • 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. How do I reset a sprite to its original position? I've been trying to follow the tutorials but couldn't find a solution. I know there is Sprite.reset method, but when I try to use it, the sprite just "flashes" quickly at the intended position and then disappears. The idea is that a when mySprite hits a sensor, it will be reset to its starting position waiting for user to start a new round. Below is some relevant code. Also if there's something unrelated I'm doing wrong, please let me know. var game = new Phaser.Game('100%', '100%', Phaser.AUTO, 'app', { preload: preload, create: create, update: update, render: render});var endSensorFixture;var map;var mySprite;var mySpriteStartingPoint;function preload() { game.load.text('map', 'map.json'); // Exported from RUBE. Contains all sprites and the game map.}function create() { game.physics.startSystem(Phaser.Physics.BOX2D); game.physics.box2d.setPTMRatio(38); game.input.addMoveCallback(dragMove); map = new Phaser.Physics.Box2D.RubeScene('map'); // Load RubeScene and initialize Box2D elements map.load(0, 0, function () { mySprite = map.getSprite('mySprite'); mySpriteStartingPoint = new Phaser.Point(mySprite.x, mySprite.y); mySprite.inputEnabled = true; //mySprite.input.enableDrag(); // does not work mySprite.body.data.SetActive(false); mySprite.events.onInputDown.add(dragStart, mySprite); mySprite.events.onInputUp.add(dragEnd, mySprite); endSensorFixture = map.getFixture('endSensorFixture'); mySprite.body.setFixtureContactCallback(endSensorFixture, onHitEndSensor, mySprite); });}function update() { updateRubeSprites();}function onHitEndSensor(body1, body2, fixture1, fixture2, begin) { endGame();}function endGame() { if (isGameRunning) { mySprite.reset(mySpriteStartingPoint.x, mySpriteStartingPoint.y); mySprite.body.data.SetActive(false); }} function dragStart() { game.physics.box2d.mouseDragStart({ x: -game.camera.x - game.input.mousePointer.x, y: game.camera.y + game.input.mousePointer.y });}function dragMove() { game.physics.box2d.mouseDragMove({ x: -game.camera.x - game.input.mousePointer.x, y: game.camera.y + game.input.mousePointer.y });}function dragEnd() { game.physics.box2d.mouseDragEnd();}I'm using Phaser 2.4.2, Box2D plugin 1.0.2 and RUBE loader.
×
×
  • Create New...