efl

Форк
0
/
physics_soft_bodies.edc 
197 строк · 4.9 Кб
1
/* This example shows how to use soft bodies.
2
 *
3
 * Soft bodies have an attribute to change how much it will
4
 * deforms when colliding. It's called "hardness", and can
5
 * be set to any value between 0.0 (soft) and 1.0 (hard).
6
 * By default, all the soft bodies are hard (1.0).
7
 *
8
 * This example will make a box and a sphere collide
9
 * many times against the floor and will be placed at
10
 * top of the screen again. They will have their hardness
11
 * modified each time, going from the default to a very
12
 * soft state.
13
 *
14
 * It can be tested with edje_player
15
 * $ edje_player physics_soft_bodies.edj
16
 */
17

18
collections {
19

20
   images {
21
      image: "bubble-blue.png" COMP;
22
   }
23

24
   group {
25
      name: "example_group";
26

27
      parts {
28
         part {
29
            name: "background";
30
            type: RECT;
31
            physics_body: NONE;
32
            description {
33
               state: "default" 0.0;
34
               color: 255 255 255 255; /* white */
35
               rel1.relative: 0.0 0.0;
36
               rel2.relative: 1.0 1.0;
37
            }
38
         }
39

40
         part {
41
            name: "red_box";
42
            type: RECT;
43
            physics_body: SOFT_BOX;
44
            description {
45
               state: "default" 0.0;
46
               color: 255 0 0 255; /* red */
47
               rel1.relative: 0.75 0.1;
48
               rel2.relative: 0.95 0.3;
49
               aspect: 1 1;
50
               physics {
51
                  ignore_part_pos: 0;
52
                  restitution: 0.85;
53
               }
54
            }
55
            description {
56
               state: "soft" 0.0;
57
               inherit: "default" 0.0;
58
               physics {
59
                  hardness: 0.8;
60
               }
61
            }
62
            description {
63
               state: "very_soft" 0.0;
64
               inherit: "default" 0.0;
65
               physics {
66
                  hardness: 0.4;
67
               }
68
            }
69
         }
70

71
         part {
72
            name: "blue_circle";
73
            type: IMAGE;
74
            physics_body: SOFT_CYLINDER;
75
            description {
76
               state: "default" 0.0;
77
               rel1.relative: 0.25 0.1;
78
               rel2.relative: 0.45 0.3;
79
               aspect: 1 1;
80
               image {
81
                  normal: "bubble-blue.png";
82
               }
83
               physics {
84
                  ignore_part_pos: 0;
85
                  restitution: 0.85;
86
                  hardness: 1;
87
               }
88
            }
89
            description {
90
               state: "soft" 0.0;
91
               inherit: "default" 0.0;
92
               physics.hardness: 0.8;
93
            }
94
            description {
95
               state: "very_soft" 0.0;
96
               inherit: "default" 0.0;
97
               physics.hardness: 0.4;
98
            }
99
         }
100

101
         part {
102
            name: "floor";
103
            type: RECT;
104
            physics_body: BOUNDARY_BOTTOM;
105
            description {
106
               state: "default" 0.0;
107
               visible: 0;
108
               physics {
109
                  restitution: 0.7;
110
               }
111
            }
112
         }
113

114
         part {
115
            name: "right_wall";
116
            type: RECT;
117
            physics_body: BOUNDARY_RIGHT;
118
            description {
119
               state: "default" 0.0;
120
               visible: 0;
121
               physics {
122
                  restitution: 1.0;
123
               }
124
            }
125
         }
126

127
         part {
128
            name: "left_wall";
129
            type: RECT;
130
            physics_body: BOUNDARY_LEFT;
131
            description {
132
               state: "default" 0.0;
133
               visible: 0;
134
               physics {
135
                  restitution: 1.0;
136
               }
137
            }
138
         }
139

140
      }
141

142
      programs {
143
         program {
144
            name: "stop,go_soft";
145
            signal: "load";
146
            in: 3 0;
147
            action: PHYSICS_STOP;
148
            target: "red_box";
149
            target: "blue_circle";
150
            after: "go_soft";
151
         }
152

153
         program {
154
            name: "go_soft";
155
            action: STATE_SET "soft" 0.0;
156
            target: "red_box";
157
            target: "blue_circle";
158
            after: "stop,go_very_soft";
159
         }
160

161
         program {
162
            name: "stop,go_very_soft";
163
            in: 3 0;
164
            action: PHYSICS_STOP;
165
            target: "red_box";
166
            target: "blue_circle";
167
            after: "go_very_soft";
168
         }
169

170
         program {
171
            name: "go_very_soft";
172
            action: STATE_SET "very_soft" 0.0;
173
            target: "red_box";
174
            target: "blue_circle";
175
            after: "stop,go_default";
176
         }
177

178
         program {
179
            name: "stop,go_default";
180
            in: 3 0;
181
            action: PHYSICS_STOP;
182
            target: "red_box";
183
            target: "blue_circle";
184
            after: "go_default";
185
         }
186

187
         program {
188
            name: "go_default";
189
            action: STATE_SET "default" 0.0;
190
            target: "red_box";
191
            target: "blue_circle";
192
            after: "stop,go_soft";
193
         }
194
      }
195

196
   }
197
}
198

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.