What should I do if the attribute value of the custom joystick _cachedSize.height cannot be obtained?

What should I do if the attribute value of the custom joystick _cachedSize.height cannot be obtained?

What are you trying to achieve ?

_cachedSize starts with an _ meaning it is basically reserved for internal use and as the name mentionned it is a cache and might not be filled in when you try to access it. Why not using adt.getSize() instead ?

2 Likes

image

I want to achieve this effect, when the pointer clicks and slides, the joystick slides with the pointer

Would you have a repro in the playground we can have a look into ?

1 Like

Line 61 “leftPuck.top = coordinates.y - adt._cachedSize.height + (leftThumbContainer._currentMeasure.width * .5) - bottomJoystickOffset”
is used to determine the y-coordinate of the joystick,

How should this line be written?

Using getSize() instead of _cachedSize as @sebavan suggested seems to correct the puck placement when clicking down. :slight_smile:

That’s true, getSize() is correct, thanks a lot for the tip :smile: :+1: