0

So let's say I have a circle object that I can move around in an open field, essentially I want to know if its possible to move the coin to a random spot, giving it an illusion of collecting a coin and spawning a new one. However I can't seem to move it when my object symbol touches the coin, can I get some help?

var randomX:Number = Math.random() * stage.stageWidth
var randomY:Number = Math.random() * stage.stageHeight
var coin:item_point = new item_point;
coin.x = randomX;
coin.y = randomY;
addChild(coin);
addEventListener(Event.ENTER_FRAME, interaction);
function interaction(event:Event):void
{
    if (mc_circle.hitTestObject(coin)){
        total += 100;
        coin.x = randomX;
        coin.y = randomY;
}
  • did you test mc_circle.hitTestPoint(randomX,randomY) ? – Yoones Mashayekhi Nov 14 '20 at 11:39
  • 1
    **(1)** Your IF statement doesn't have a closing `}` **(2)** Also in the IF block you should generate two new random values _eg:_ `coin.x = Math.random() * stage.stageWidth;` – VC.One Nov 14 '20 at 11:42

0 Answers0