Melchester
Melchester

Reputation: 421

Super fast disappearing Child

I am trying to explore the limits of what we are consciously aware of ... okay that sounds terribly pretentious, basically how long something has to be visible for for us to notice. But I cannot get my child to disappear fast enough.

        valueX = SKLabelNode(fontNamed: "ArialRoundedMTBold")
        valueX.position = CGPoint(x: 0, y: 0)
        valueX.fontSize = 320
        valueX.text = String("H")
        valueX.fontColor = SKColor.white
        self.addChild(valueX)
        valueX.run(SKAction.scale(to: 0, duration: 0.00001))

This should be too fast to see, but it seems to stay for around a second. Is there some other technique I can use to make something appear very briefly?

Upvotes: 0

Views: 50

Answers (1)

Steve Ives
Steve Ives

Reputation: 8134

I don't think that the SK engine will scale the sprite in-between draws i.e. screen refreshes, so it'll have to be on screen at full size for at least 1 frame, which is 1/60s. I suspect that the SK engine then works out how much to scale per frame, so in the next frame it's probably completely gone. E.g. if you wanted to scale to 25% over 1 second, SK would think that it's been 0.01666667s since the last draw, so the amount to scale by is 1/60 x 75% = 1.25%.

If the duration of the action is less than the time per frame, the effect will be 100% one frame and 0% the next.

If you research 'human persistence of vision' you'll find a lot of information (which I've not gone into myself), which may be why it appears to 'stay for around a second' rather than just 1/60s

As a very basic check, put a sprite on screen in didMoveTo(:view) at a random point then move it to a random point in update(), so it'll move every time update() runs (every 1/60s). If you see it flickering around, you'll know that you can perceive something appearing for 1/60th second but you won't be able to get this done any faster.

Upvotes: 1

Related Questions