Author Topic: Changing an Actor's scale without moving  (Read 15167 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Changing an Actor's scale without moving
« on: April 02, 2016, 12:40:35 PM »
How does one go about changing the scale of an object while it's standing in place? I've tried manipulating the scaleX and scaleY properties of my Actor, but it does nothing. Do those properties even do what I'm expecting them to do? Do I have to use the horizon scaler instead and change the near and far distance variables dynamically to do what I want? I don't see why I'd have to if I can just manipulate that property manually. Is this even right? I threw this in my doit method:

Code: [Select]
(if (== scaleAnimate TRUE)
(actorShrink
scaleX: (- (actorShrink scaleX?) 1)
scaleY: (- (actorShrink scaleY?) 1)
)
)

I'm assuming the '?' there requests the value of that property, correct? Still getting the hang of Sierra SCI syntax.
« Last Edit: April 02, 2016, 12:42:41 PM by MusicallyInspired »


Brass Lantern Prop Competition

Offline lskovlun

Re: Changing an Actor's scale without moving
« Reply #1 on: April 02, 2016, 12:58:30 PM »
How does one go about changing the scale of an object while it's standing in place? I've tried manipulating the scaleX and scaleY properties of my Actor, but it does nothing. Do those properties even do what I'm expecting them to do? Do I have to use the horizon scaler instead and change the near and far distance variables dynamically to do what I want? I don't see why I'd have to if I can just manipulate that property manually. Is this even right? I threw this in my doit method:

Code: [Select]
(if (== scaleAnimate TRUE)
(actorShrink
scaleX: (- (actorShrink scaleX?) 1)
scaleY: (- (actorShrink scaleY?) 1)
)
)

I'm assuming the '?' there requests the value of that property, correct? Still getting the hang of Sierra SCI syntax.
Have you tried (actorShrink forceUpd:) ?

Offline Kawa

Re: Changing an Actor's scale without moving
« Reply #2 on: April 02, 2016, 01:19:31 PM »
All ScummVM-patched timing issues aside, here's what Freddy Pharkas does to zoom in its logo:
Code: [Select]
(1
(= local6 0)
(yellSound number: 2918 flags: 1 loop: 1 play:)
(titleView1
setScale: 10 ;<-- start small
setScale: ;<-- interesting!
setPri: 15
setLoop: 0
setStep: 5 5
)
(= local2 10)
(while (< local2 129)
(Animate (gCast elements?) 1)
(titleView1 scaleX: local2 scaleY: local2 show:) ;<-- the show call is also quite interesting.
(= local2 (+ local2 6))
)
(= cycles 1)
)

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #3 on: April 02, 2016, 01:36:58 PM »
Also, I can't seem to use the increment or decrement operators:

Code: [Select]
--vVariable
...doesn't work, even though the Companion help file says it should.
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #4 on: April 02, 2016, 01:54:31 PM »
In the Freddy example, what does this do?

Code: [Select]
(Animate (gCast elements?) 1)
Brass Lantern Prop Competition

Offline lskovlun

Re: Changing an Actor's scale without moving
« Reply #5 on: April 02, 2016, 02:07:15 PM »
In the Freddy example, what does this do?

Code: [Select]
(Animate (gCast elements?) 1)
That's the kernel call that updates the graphics on screen. Easily the most complicated thing in SCI16. Without it, you'd just have a tight loop doing nothing.

EDIT: But since your code runs in the context of the main game loop, calling it would solve nothing (and perhaps even cause glitching). It is already being called by the template game.
« Last Edit: April 02, 2016, 02:09:08 PM by lskovlun »

Offline Kawa

Re: Changing an Actor's scale without moving
« Reply #6 on: April 02, 2016, 02:08:23 PM »
Also, I can't seem to use the increment or decrement operators:

Code: [Select]
--vVariable
...doesn't work, even though the Companion help file says it should.
Use (-- vVariable), with a space.
In the Freddy example, what does this do?

Code: [Select]
(Animate (gCast elements?) 1)
It renders the changes, is all I understand of it.

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #7 on: April 02, 2016, 02:27:50 PM »
Well, if the Animate command is not used then no animation occurs on screen. In fact, it doesn't even "show:". But when it's there it works. So, it works with the Freddy code (forceUpd: does not work). I don't even need the doit method in this case. I think the "show:" is only there to make the thing appear for the first time, it's just called redundantly each time the loop repeats. The "setScale: ;" is also necessary, if it's not there there is no animation either. Though, "setScale: 10;" (or in my case 100) doesn't need to be there at all, I suppose seeing as I'm shrinking from 100% scaling instead of enlarging.
« Last Edit: April 02, 2016, 02:33:54 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Changing an Actor's scale without moving
« Reply #8 on: April 02, 2016, 04:15:40 PM »
rm141 in my "Explore SCI 1.1" game does this. It's a simple matter of using ScaleTo:

Code: [Select]
(portal setScale: ScaleTo portalSize)

It animates over time to the new scale though - maybe that's not what you want. You can probably change that by using an instance of ScaleTo, and then specifying a step or changing the waitCount or something (just giving the ScaleTo code a quick look over, not sure what will work).
« Last Edit: April 02, 2016, 04:18:21 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline troflip

Re: Changing an Actor's scale without moving
« Reply #9 on: April 02, 2016, 04:20:07 PM »
Also, I can't seem to use the increment or decrement operators:

Code: [Select]
--vVariable
...doesn't work, even though the Companion help file says it should.

kawa got you pointed in the right direction, but would you be able to point me to where in the help file it still uses that syntax? I thought I changed everything to the new syntax.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #10 on: April 02, 2016, 05:00:20 PM »
"Help/StudioCompiler/arithmetic.html?highlight=decrement"

It also incorrectly shows how else statements work with if. In the help file it shows "else" with its own brackets, but it's supposed to just sit inside "if" without any brackets.

Also, it seems the caveat of doing the scaling animation this way with the Freddy code is that it does not accept any user interface input at all until the animation is finished, and then it triggers everything you pressed while you were waiting. Probably why the Animate command is needed as it must put the entire game loop on hold to do its own thing. This is what I'm using right now. In order to get it to scale at an acceptable speed I had to throw in Wait commands in nested if statements. I'm sure there's a better way to do this. I'm also trying to begin fading it to black after it reaches a certain scale threshold.

Code: [Select]
(1
(Palette
palSET_INTENSITY
0
254
100
)
(actorShrink
setScale:
setPri: 15
setLoop: 0
setStep: 5 5
)
(= actorScale 128)
(= actorIntensity 100)
(while (> actorScale 0)
(Animate (gCast elements?) 1)
(actorShrink scaleX: actorScale scaleY: actorScale)

(-- actorScale)
(if (< actorScale 100)
(-- actorIntensity)
(Palette
palSET_INTENSITY
0
63
actorIntensity
)
)
(if (> actorScale 64)
(Wait 4)
else
(if (> actorScale 32)
(Wait 3)
else
(Wait 2)
)
)
)
(self cue:)
)
« Last Edit: April 02, 2016, 05:16:56 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Changing an Actor's scale without moving
« Reply #11 on: April 02, 2016, 05:16:54 PM »
"Help/StudioCompiler/arithmetic.html?highlight=decrement"

It also incorrectly shows how else statements work with if. In the help file it shows "else" with its own brackets, but it's supposed to just sit inside "if" without any brackets.

Umm... that's the documentation for the SCI Studio compiler.

SCI Studio syntax:
http://scicompanion.com/Documentation/StudioCompiler/arithmetic.html

Sierra syntax:
http://scicompanion.com/Documentation/Compiler/arithmetic.html


For the scaling issue, have you tried using ScaleTo yet?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #12 on: April 02, 2016, 05:21:50 PM »
*shrug* I clicked on SCI Companion Help and that's where it took me.

Giving ScaleTo a shot now. At a glance it looks like exactly what I need.
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Changing an Actor's scale without moving
« Reply #13 on: April 02, 2016, 05:27:15 PM »
Ok, it's not working. It's being called but it doesn't actually animate. It just sits there.
Brass Lantern Prop Competition

Offline troflip

Re: Changing an Actor's scale without moving
« Reply #14 on: April 02, 2016, 05:29:32 PM »
Ok, it's not working. It's being called but it doesn't actually animate. It just sits there.

Can you post your code? Again, I do this thing exactly in the "explore SCI 1.1 game", and it works fine.

Quote
*shrug* I clicked on SCI Companion Help and that's where it took me.

It should take you to the help index page.
Check out my website: http://icefallgames.com
Groundhog Day Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.087 seconds with 22 queries.