enpu

Members
  • Content count

    1,230
  • Joined

  • Last visited

  • Days Won

    17

enpu last won the day on March 2

enpu had the most liked content!

4 Followers

About enpu

  • Rank
    Advanced Member
  • Birthday 04/21/1985

Contact Methods

  • Website URL
    https://www.panda2.io
  • Twitter
    ekelokorpi
  • Skype
    eemelikelokorpi

Profile Information

  • Gender
    Male
  • Location
    Finland

Recent Profile Visitors

4,859 profile views
  1. Inserting Sprite into Anim Bug?

    @Ninjadoodle game.addAsset('anim1.png'); game.addAsset('anim2.png'); game.addAsset('anim3.png'); game.addAsset('sprite.png'); game.createScene('Main', { init: function() { var anim = new game.Animation([ 'anim1.png', 'anim2.png', 'anim3.png' ]); anim.play(); anim.addTo(this.stage); var sprite = new game.Sprite('sprite.png'); sprite.position.set(100, 100); sprite.addTo(anim); } }); Seems to be working fine here. Can you give me code example?
  2. @Ninjadoodle Yes you are. backgroundColor is attribute of Scene class, not System https://www.panda2.io/docs/api/Scene
  3. Font Questions

    @greencoder There is no tint property in Text class (Text extends from Container class), tint is only in Sprite class (https://www.panda2.io/docs/api/Sprite). What Text class actually does, is that it generates Sprites for every character of the text and adds them as child to the container. That means you could loop through every character Sprite and apply tint to them. for (var i = 0; i < this.mVersionText.children.length; i++) { var char = this.mVersionText.children[i]; char.tint = '#00ff00'; char.tintAlpha = 0.5; } That is a bit heavy process since it goes through every character. If you are going to tint all characters with same color and alpha, a good trick would be to cache the container into one sprite and then tint that. this.mVersionText.cache = true; this.mVersionText._cachedSprite.tint = '#00ff00'; this.mVersionText._cachedSprite.tintAlpha = 0.5; Settings cache property to true will render the whole content of a container into one sprite and store that into private property called _cachedSprite.
  4. parse JSON

    https://www.panda2.io/examples#core-getJSON
  5. Instant Games Question

    @greencoder var playerName = FBInstant.player.getName(); Instant Games SDK documentation is here: https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.1
  6. Collision Detection Question

    Oh well then that's the issue, the hitTest function assumed that you are using the whole image. It used the rectWidth and rectHeight values to determine the center position of the rectangle, but since you were using values that are lower than the actual image, the center position would be off. hitTest: function(rect, circle, rectWidth, rectHeight, circleRadius) { rectWidth = rectWidth || rect.width; rectHeight = rectHeight || rect.height; circleRadius = circleRadius || circle.width / 2; var rectCenterX = rect.x + Math.cos(rect.rotation) * (rect.width / 2 - rect.anchor.x) - Math.sin(rect.rotation) * (rect.height / 2 - rect.anchor.y); var rectCenterY = rect.y + Math.sin(rect.rotation) * (rect.width / 2 - rect.anchor.x) + Math.cos(rect.rotation) * (rect.height / 2 - rect.anchor.y); var circleCenterX = circle.x - circle.anchor.x + circleRadius; var circleCenterY = circle.y - circle.anchor.y + circleRadius; var circleX = Math.cos(-rect.rotation) * (circleCenterX - rectCenterX) - Math.sin(-rect.rotation) * (circleCenterY - rectCenterY) + rectCenterX; var circleY = Math.sin(-rect.rotation) * (circleCenterX - rectCenterX) + Math.cos(-rect.rotation) * (circleCenterY - rectCenterY) + rectCenterY; var close = new game.Vector(circleX, circleY); if (circleX < rectCenterX - rectWidth / 2) { close.x = rectCenterX - rectWidth / 2; } else if (circleX > rectCenterX + rectWidth / 2) { close.x = rectCenterX + rectWidth / 2; } if (circleY < rectCenterY - rectHeight / 2) { close.y = rectCenterY - rectHeight / 2; } else if (circleY > rectCenterY + rectHeight / 2) { close.y = rectCenterY + rectHeight / 2; } if (close.distance(circleX, circleY) < circleRadius) return true; }, Try this one
  7. Collision Detection Question

    Hmm interesting, then that's not the issue. Could you test your images (laser and spinvader) with the example scene: https://www.panda2.io/examples#misc-hitTest Does it work as expected?
  8. Collision Detection Question

    Well do you understand the difference between local and world position? I can see that you are adding your laser.png to game.scene.bg container and spinvader.png to game.scene.mg container? Is the world positions of those containers same? If not then that's your problem.
  9. Collision Detection Question

    The hit test function uses local positions for the hit detection. So if your rect and circle has different origin (position 0,0 is not same place) then that is definitely the issue. To fix that, you should get world positions for both and then replace all the rect.x, rect.y, circle.x, circle.y values
  10. register mouse clicks on word object

    try to make the object interactive: this.world.interactive = true;
  11. Collision Detection Question

    Really hard to say without any code example
  12. Collision Detection Question

    @Ninjadoodle https://www.panda2.io/examples Just added the misc examples in the bottom of the list. I modified the hit test function, so you can define rectangle width and height as well as the circle radius.
  13. Check if a Spine animation is complete

    Here is full example of Spine events: game.createScene('Events', { init: function() { var player = new game.Spine('spineboy.json'); player.position.x = game.width / 2; player.position.y = game.height - 100; player.state.addListener({ start: this.start.bind(this), complete: this.complete.bind(this), event: this.event.bind(this) }); player.play('run', true); player.addTo(this.stage); }, start: function(entry) { console.log('Animation started'); }, complete: function(entry) { console.log('Animation completed'); }, event: function(entry, event) { // User-defined event console.log(event.data.name); } }); More info about Spine events: http://esotericsoftware.com/spine-unity-events
  14. Check if a Spine animation is complete

    @lars Try this: player.state.addListener({ complete: function(entry) { } });
  15. it's late but text isn't showing up

    @obliviot Can't see anything wrong with the code. Do you have also the font.png file in your media folder?