Scale item object

  • #10, by ke4Wednesday, 30. September 2015, 16:03 6 years ago
    Nice.

    I just don't get it what's the trick? What makes it more smooth? ( But it still not perfect, don't know why )
    Mine script works as well, but just not as smooth but both use :to() function

    i would just add somewhere
    game.GameUsedItem:getName() ~= game.CurrentObject:getName()
    1
    2


    Because i'm covering the dragged item with a black tile. So i guess into the 19 line?

    Key Killer

    810 Posts


  • #11, by afrlmeWednesday, 30. September 2015, 16:15 6 years ago
    Hmm what I wrote covers mouse enters & leaves. The item would still exist underneath the tile, so it doesn't really matter all that much about adding your line. Or are you wanting to use the scaled version for the cursor too?

    The easing options control how it transitions from current value to the target value. easeQuadOut will slow down towards the end of the transition. If you want it smooth completely then you should probably use easeLinearInOut as that will have a constant speed throughout.

    P.S: I believe items are placed into the center of the defined item slot areas you defined. So when you are scaling it up or down the system is trying to counter the offset.

    If you were to scale up a scene object, it would scale down & to the right as the top left pixel of a sprite is what defines the position of said sprite. The only way you would be able to keep a scene object centered to its spot when scaling is to calculate the offset based on current scale value from the position it would be at 100%.

    Imperator

    7005 Posts

  • #12, by ke4Wednesday, 30. September 2015, 16:28 6 years ago
    Ah, yeah i didn't know that it uses the image when it's set...
    i deleted it and use only the animation, so in that case it's really pointless.

    Did you watch the youtube video i uploaded? It's hard to describe, the animation itself is smooth but it's like vibrating or jumping during the animation. Not even easeLinearInOut helps in that.

    I thought that you wrote the function because of that, otherwise i already used easings in the first script, but either way it's smoother with yours what i don't understand what's causing it.

    Edit: That's probably the counting thing then...

    Key Killer

    810 Posts

  • #13, by afrlmeWednesday, 30. September 2015, 16:38 6 years ago
    I'm not 100% sure that that is what it is doing. But it sure looks like it is centering the item to the item area. The only thing I know is that the interaction polygons for items & characters are automatically generated by the engine.

    P.S: your script may have been looping between scaling up & back down each time you moved the mouse. I can't say for sure though as I didn't test the script you wrote. My script only scales 1 time per item & only resets the state & itm variable if there's nothing below the cursor belonging to the object table. The thing is that as soon as you move the cursor away from the item, you are entering an object belonging to the button table, so it will call the reset & scale all objects down. Whereas when the current object is still the item it will not scale up or call the reset function except the first time you scale up. It's all about adding counter-measures to prevent the engine from trying to do things you don't want it to do.

    Imperator

    7005 Posts

  • #14, by ke4Wednesday, 30. September 2015, 16:46 6 years ago
    Right, i didn't even realize that :-) There is always so much things to keep in mind.
    I'm always just trying to wrote the script as short as possible as i'm scared that there will be too much scripts to handle and the whole game will be laggy.

    I'm mean i have a loop showing and reseting the item tiles. ( function which runs on mouse move )
    Loop moving with character shadow.
    And now this loop.

    But unfortunately when its "jumping" like that it doesn't give the nice effect, but looks rather weird.

    Key Killer

    810 Posts

  • #15, by afrlmeWednesday, 30. September 2015, 16:57 6 years ago
    I guess there's not really much I can do about the jumping thing (as you call it). Try using different delay & scale values. I guess the sure fire way of not having it jump at all would be to use a delay of 0, then you wouldn't even need to use the to tween function either.

    * edit: nope, that causes it to vibrate slightly before updating itself to the correct position also. Sorry. Nothing I can do about that.

    You could animate the scaling manually I suppose by forcing the frames.

    Imperator

    7005 Posts

  • #16, by ke4Wednesday, 30. September 2015, 17:05 6 years ago
    Hmm, so i guess there are 3 options to do:

    1. Do nothing

    2. Instead of zooming use some highlights around the item.
    Or change the image to bigger version and then it would be something like the zoom with 0 delay.

    3. Animate it directly in the item animation, there would be looping only the first frame and on hover it would play first half of the animation which would be zooming in and on leave the second half which would be zooming out.
    ...well something like that.

    Key Killer

    810 Posts

  • #17, by afrlmeWednesday, 30. September 2015, 17:15 6 years ago
    2 & 3 are pretty much the same thing. You would add the .AnimationFirstFrame & .AnimationLastFrame Lua fields into your first frame & again for the end frame where you want it to end. You don't need a scale up or down animation. One should suffice as you can use Lua to control the playback mode of the animation (forwards, backwards, random). As long as the actual image / width of the item animations are all the same size I believe it should stay centered without trying to correct itself.

    By the way, did you know that you can actually create loops with animation frames? Each time it loops back to a frame containing actions associated with the frame it will execute those actions.

    So even without tweening you could animate something like some clouds moving across the screen & then have them reset back to initial position when they get to a specific coordinate - all from inside of a single animation frame with a small if query & you wouldn't even need to use Lua script. grin

    Imperator

    7005 Posts

  • #18, by ke4Wednesday, 30. September 2015, 17:25 6 years ago
    Well i have never thought about it like that & think it could come handy.

    And i don't think that 1 is the way to go as i wanto create a cool game grin
    So i'm gonna do it through the item animation and the animation's actions.

    Thanks for help.

    Key Killer

    810 Posts

  • #19, by afrlmeWednesday, 30. September 2015, 17:39 6 years ago
    What I was trying to say with my little italic tip is that you could add if queries into the first & last frame to check if current object = the name of the item & if it is then you set animation direction to forwards then force the frames to play between x & y to the last frame else you force it to loop frame 1 only. Then in last frame, you listen for when current object does not equal the name of the object & set direction as backwards & update frames to play from first frame to last frame else have it force it to loop the last frame. Just think of it as a on mouse enter / leaves action but done inside of 2 animation frames instead. wink

    Imperator

    7005 Posts

  • #20, by ke4Wednesday, 30. September 2015, 17:58 6 years ago
    Yes i like your italic little tips grin

    Just tried and it's easy to set up and works smoothly as i was imagining.
    But doesn't that means that now all the items will be constantly checking for mouse enter + i need to do it manually for every item + i can't set the pause to 999 to spare the system.
    But it's pretty cool way to manage it!

    Can i get somehow the name if the current item dynamicly inside of the animation?

    Key Killer

    810 Posts