States help remember information in your prototype. Pulses are used to tell patches to perform an action. Understanding how these work together will help you be more effective at building Origami prototypes.
状态帮助记住原型中信息。脉冲用来告诉模块反馈哪个动作。了解这些工作方式有助于更有效地构建原型。
板栗:跟电路图其实差不多。【打开开关 → 电流通过 → 点亮灯泡】:打开 = 交互和操作模块;开关 = 交互对象模块;电流通过 = 发送脉冲;点亮灯泡 = 切换为定义的状态。
States 状态
A state is a value that persists over time. The simplest version of state is in the Switch patch. Switches are either on or off, and they remain that way until you tell them otherwise.
状态是一个值持续的时间。板栗:也就字面意思,跟“今天状态不好,昨天状态特别好”一个意思.
举个例子,最简单的能实现状态切换的模块是 Switch 开关 模块。在没有 打开 或 关闭 前,状态是会保持不变的。
If we look at a state as it changes over time, it might look something like this:
假设开关本来是一个关闭,我们在 Frame 5 那里点了下开关,那状态图形化之后可能看起来是下面图中那样:
A switch is off until you turn it on. You can see the state goes from off to on immediately in a single frame. A frame is usually 1/60th of a second.
可以看到状态 Frame 1~4 是关闭的,Frame 5 之后开启了。
一个帧通常是1/60秒。板栗:这句不用管了,这里说还挺干扰的...
Pulses 脉冲
While state persists over time, pulses are On ✓ only for a single frame. The value of the cable sending the pulse is otherwise off.
A pulse over time looks like this:
状态是一个持续时间,脉冲就不是,脉冲只持续一帧,把信息发送到了就撤了。 否则,这条线路就被占用了不能在发送其他的脉冲了。
状态的可视化图形大概就下面这样的:
our can see that pulses are only On ✓ for a single frame.
They're used to tell patches to perform an action, like telling a Switch to turn on or turn off. They're also useful for passing along user interactions like tapping on the screen or pressing a key on the keyboard.
可以在图上看到脉冲只在 Frame 5 上显示了一下。用于告诉模块 赶紧的切换状态啊!,打开或关闭开关。
脉冲还可用于传递用户交互,例如在屏幕上点击或按键盘上的键。
板栗:其实吧我觉得所有的信息都是通过脉冲传递的。
Examples of State & Pulses 状态和脉冲的例子
The [Switch] patch outputs the state of the switch (on / off) and accepts pulses to flip the switch, turn it on, or turn it off.
Switch 模块接收一个交互模块发出的脉冲,根据指令输出开关的状态将其打开或关闭。
The Interaction patch has Down and Tap outputs. Down represents the state of whether the finger is currently down on the screen. The Tap port outputs a pulse when the finger is released from the screen.
Interaction 模块有 Down 和 Tap 输出口。Down 表示手指在屏幕上按下时的状态,按下时输出脉冲。Tap 表示手指在屏幕上按下 - 松开时的状态,松开输出脉冲。
The Counter patch outputs the state of the counter (the number value) and accepts pulses to increase it or decrease it.
Counter 模块输出计数器的状态(数值)并接受来自其他模块的脉冲增加或减少数值。
Creating Pulses from State 给状态创建一个脉冲
There are a couple ways to create a pulse from state. The more explicit way is to use the Pulse patch. The Pulse patch accepts a state called On/Off and will output a pulse on the Turned On port when the state turns on and the Turned Off port when the state turns off. This is an example that flips a switch the moment the user touches the screen.
有几种方法从状态创建脉冲。 更明确的方法是使用[Pulse]模块。 [Pulse]模块接受一个称为On / Off的状态,并在状态打开时在Turned On端口输出脉冲,当状态关闭时,将输出Turned Off端口的脉冲。 这是在用户触摸屏幕的瞬间翻转开关的示例。
试了个加Pulse模块的跟不加的也没区别啊!!
Another way is to infer a state change is to connect a state directly to a port accepting a pulse. What'll happen is the port that accepts a pulse will look to when the state changes from off to on, and at that moment infer a pulse. So if you wanted a switch to flip when the user's finger touches down on the screen, you can connect the Down port directly to the Switch's Flip port, without needing to use a Pulse patch.
这两节不懂
Temporary State with the Delay patch 临时状态和 Delay 模块
Sometimes you need a state to turn on for a few moments and then turn off. For example, say you were making a confirmation window appear for a couple seconds after the user pressed a button. You could do this using a Switch, but then you'd need to build logic that turns the switch off after some time. A simpler way to do this is to use the Delay patch.
有时你需要一个状态打开一会儿,然后自动关闭。
这里假设一个交互,用户按下按钮后出现确认窗口几秒钟,然后自动关闭。
可以使用 Switch 模块来做到这一点,但是你需要建立“在一段时间后关闭开关”的逻辑,一个更简单的方法是使用 ** Delay D
**模块替换 Switch。
The Delay patch can take state that's changing and delay the change by an amount of time you specify. You can also tell it whether to only delay increasing (off to on) or decreasing (on to off) changes. If you give a Delay patch a pulse as input, you can delay the change from on to off, extending the pulse for any amount of time you'd like.
Delay 模块可以采取正在更改的状态,并将更改延迟时间设置为指定的值。还可以定义类型是有操作就激活,还是只在关闭到打开或打开到关闭时更改。
◀︎ Coordinates 坐标 ・ Patches 模块 - Animation 动画 - Bouncy Converter ▶︎