YesNoOk
avatar

Trying to properly scale an Explod with ModifyExplod but with no luck (Read 21056 times)

Started by GhostArrow, September 02, 2021, 10:10:03 pm
Share this topic:
Trying to properly scale an Explod with ModifyExplod but with no luck
#1  September 02, 2021, 10:10:03 pm
  • *
    • Canada
Hi guys, I've been working on developing my first character. It's been a lot of fun and I've learned a lot, but I've finally hit a snag that I can find absolutely no answer for.
I have an animation that plays inside a custom power bar. The animation is set to look a certain way when the power gauge is full. The animation is called as an Explod based on the value of a variable. Then I am trying to scale the animation (Explod) with ModifyExplod with the changes in that variable. Everything is working fine except it is scaling in the wrong direction. The animation should start small (smallest scale) from the right side of the bar (for 1P) and then gradually scale bigger out to the left until it reaches its full size. Like this:
                               <-|
                         <-| <-|   
                   <-| <-| <-| 
             <-| <-| <-| <-|

etc. The 2P version should look like the 2nd one down below. I found this post in my searching which led me to believe the direction building could be based on the animation's position relative to the axis:
Re: Help scaling Explod for a custom powerbar in MUGEN 1.1

But still no luck. No matter what I've tried, the animation either always scales incorrectly like this:
<-|
<-| <-|
<-| <-| <-|
<-| <-| <-| <-|
<-| <-| <-| <-| <-|
Or it gets flipped and plays correctly but in the wrong direction:
|->
|->|->
|->|->|->
|->|->|->|->
|->|->|->|->|->

I've also tried switching it's postype from left to right but still no luck. So any tips for what I'm missing?
Re: Trying to properly scale an Explod with ModifyExplod but with no luck
#2  September 07, 2021, 08:43:37 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Can you show us the code please? I like using full size bars and starting them scaled down rather than 1 pixel bars and scaling up. The 0,0 on the axis can cause issues your sprite can and will be on one side or the other which makes a difference for how the scaling behaves.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Trying to properly scale an Explod with ModifyExplod but with no luck
#3  September 07, 2021, 04:43:19 pm
  • *
    • Canada
I like using full size bars and starting them scaled down rather than 1 pixel bars and scaling up.

This is how I've made it. It's a full size animation that gets scaled down and then scales up to its full size.

The 0,0 on the axis can cause issues your sprite can and will be on one side or the other which makes a difference for how the scaling behaves.

This is what I thought it might have to do with. I've got it set to the exact place that "President Devon" had theirs positioned in the post I linked. Was hoping for some insight into the best way to position it so that it should scale correctly.
Here is President Devon's example:



The difference with mine is that mine is a 20 frame animation with different size sprites. But I've tried to position it so that the top left-most area on longest sprite in the animation is touching the 0,0 point of the axis, inside the bottom right quadrant. Just like President Devon's. I guess since the animation has sprites of different lengths, it could also cause scaling issues?

Here's the code that I think would matter:
Code:
[State -2, Gauge Anim]
type = Explod
trigger1 = NumExplod(8600)=0
trigger1 = TeamSide = 1
trigger1 = var(3) != 1
anim = 8600
ID = 8600
pos = 25,343
postype = Left
sprpriority = 8
ownpal = 1
bindtime = -1
removetime = -1


[State -2, ModifyExplod]
type = ModifyExplod
trigger1 = NumExplod(8600) = 1
trigger1 = TeamSide = 1
trigger1 = Var(3) != 1
id = 8600
scale = fvar(8),1
ignorehitpause = 1


[State -2, ]
Type = Varadd
triggerall = var(13) > life
triggerall = MoveType = H
triggerall = fvar(8) <= 1
triggerall = var(3) != 1
trigger1 = NumExplod(8500) = 1 && NumExplod(8800) = 0
trigger2 = NumExplod(8550) = 1 && NumExplod(8850) = 0
fvar(8) = (var(13)-life) * 0.0015
Persistent = 0
ignorehitpause = 1

[State -2, ]
type = Varset
trigger1 = 1
var(13) = life


I also meant to look up the current best practice for setting an Explod gauge's position so that it will appear at the same place on the screen no matter what resolution you use. But I couldn't figure out how to adapt the code I found for my character. You can see in my code it is just positioned for the best spot on my resolution. Any tips for fixing that would be appreciated as well  :)
Re: Trying to properly scale an Explod with ModifyExplod but with no luck
#4  September 25, 2021, 03:45:28 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
I’m super rusty and just happened to pop on for a sec, so I may be wrong about the following:

I think your problem is that sometimes p1 is facing one way or the other when this activates.
When p1 calls an explod it is facing in their direction by default.  I think this is causing your problem with postype = left.  If postype = back, then the explod would instead spawn in a matching facing by default.

But you are correct to use postype = left for this situation.  You just need to add a facing param to check p1’s facing and flip if necessary.
Something line this (I may have this reversed)

facing = cond(facing=1,-1,1)

Re: Trying to properly scale an Explod with ModifyExplod but with no luck
#5  October 04, 2021, 12:19:19 am
  • *****
  • Shame on you!
    • USA
If it's not spawning in the right spot, adjust the pos x value so it does. You'll also want the anim's positioning to the left of the 0 point, not the right.
You could then use the scale and a posadd to adjust it on screen.
vVv Ryuko718 Updated 10/31/22 vVv