1 /** 2 A node used to create a parallax scrolling background. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.parallaxbackground; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.canvaslayer; 24 import godot.node; 25 /** 26 A node used to create a parallax scrolling background. 27 28 A ParallaxBackground uses one or more $(D ParallaxLayer) child nodes to create a parallax effect. Each $(D ParallaxLayer) can move at a different speed using $(D ParallaxLayer.motionOffset). This creates an illusion of depth in a 2D game. If not used with a $(D Camera2D), you must manually calculate the $(D scrollOffset). 29 */ 30 @GodotBaseClass struct ParallaxBackground 31 { 32 enum string _GODOT_internal_name = "ParallaxBackground"; 33 public: 34 @nogc nothrow: 35 union { godot_object _godot_object; CanvasLayer _GODOT_base; } 36 alias _GODOT_base this; 37 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 38 package(godot) __gshared bool _classBindingInitialized = false; 39 package(godot) static struct _classBinding 40 { 41 __gshared: 42 @GodotName("_camera_moved") GodotMethod!(void, Transform2D, Vector2) _cameraMoved; 43 @GodotName("set_scroll_offset") GodotMethod!(void, Vector2) setScrollOffset; 44 @GodotName("get_scroll_offset") GodotMethod!(Vector2) getScrollOffset; 45 @GodotName("set_scroll_base_offset") GodotMethod!(void, Vector2) setScrollBaseOffset; 46 @GodotName("get_scroll_base_offset") GodotMethod!(Vector2) getScrollBaseOffset; 47 @GodotName("set_scroll_base_scale") GodotMethod!(void, Vector2) setScrollBaseScale; 48 @GodotName("get_scroll_base_scale") GodotMethod!(Vector2) getScrollBaseScale; 49 @GodotName("set_limit_begin") GodotMethod!(void, Vector2) setLimitBegin; 50 @GodotName("get_limit_begin") GodotMethod!(Vector2) getLimitBegin; 51 @GodotName("set_limit_end") GodotMethod!(void, Vector2) setLimitEnd; 52 @GodotName("get_limit_end") GodotMethod!(Vector2) getLimitEnd; 53 @GodotName("set_ignore_camera_zoom") GodotMethod!(void, bool) setIgnoreCameraZoom; 54 @GodotName("is_ignore_camera_zoom") GodotMethod!(bool) isIgnoreCameraZoom; 55 } 56 bool opEquals(in ParallaxBackground other) const { return _godot_object.ptr is other._godot_object.ptr; } 57 ParallaxBackground opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 58 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 59 mixin baseCasts; 60 static ParallaxBackground _new() 61 { 62 static godot_class_constructor constructor; 63 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ParallaxBackground"); 64 if(constructor is null) return typeof(this).init; 65 return cast(ParallaxBackground)(constructor()); 66 } 67 @disable new(size_t s); 68 /** 69 70 */ 71 void _cameraMoved(in Transform2D arg0, in Vector2 arg1) 72 { 73 Array _GODOT_args = Array.empty_array; 74 _GODOT_args.append(arg0); 75 _GODOT_args.append(arg1); 76 String _GODOT_method_name = String("_camera_moved"); 77 this.callv(_GODOT_method_name, _GODOT_args); 78 } 79 /** 80 81 */ 82 void setScrollOffset(in Vector2 ofs) 83 { 84 checkClassBinding!(typeof(this))(); 85 ptrcall!(void)(_classBinding.setScrollOffset, _godot_object, ofs); 86 } 87 /** 88 89 */ 90 Vector2 getScrollOffset() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(Vector2)(_classBinding.getScrollOffset, _godot_object); 94 } 95 /** 96 97 */ 98 void setScrollBaseOffset(in Vector2 ofs) 99 { 100 checkClassBinding!(typeof(this))(); 101 ptrcall!(void)(_classBinding.setScrollBaseOffset, _godot_object, ofs); 102 } 103 /** 104 105 */ 106 Vector2 getScrollBaseOffset() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(Vector2)(_classBinding.getScrollBaseOffset, _godot_object); 110 } 111 /** 112 113 */ 114 void setScrollBaseScale(in Vector2 scale) 115 { 116 checkClassBinding!(typeof(this))(); 117 ptrcall!(void)(_classBinding.setScrollBaseScale, _godot_object, scale); 118 } 119 /** 120 121 */ 122 Vector2 getScrollBaseScale() const 123 { 124 checkClassBinding!(typeof(this))(); 125 return ptrcall!(Vector2)(_classBinding.getScrollBaseScale, _godot_object); 126 } 127 /** 128 129 */ 130 void setLimitBegin(in Vector2 ofs) 131 { 132 checkClassBinding!(typeof(this))(); 133 ptrcall!(void)(_classBinding.setLimitBegin, _godot_object, ofs); 134 } 135 /** 136 137 */ 138 Vector2 getLimitBegin() const 139 { 140 checkClassBinding!(typeof(this))(); 141 return ptrcall!(Vector2)(_classBinding.getLimitBegin, _godot_object); 142 } 143 /** 144 145 */ 146 void setLimitEnd(in Vector2 ofs) 147 { 148 checkClassBinding!(typeof(this))(); 149 ptrcall!(void)(_classBinding.setLimitEnd, _godot_object, ofs); 150 } 151 /** 152 153 */ 154 Vector2 getLimitEnd() const 155 { 156 checkClassBinding!(typeof(this))(); 157 return ptrcall!(Vector2)(_classBinding.getLimitEnd, _godot_object); 158 } 159 /** 160 161 */ 162 void setIgnoreCameraZoom(in bool ignore) 163 { 164 checkClassBinding!(typeof(this))(); 165 ptrcall!(void)(_classBinding.setIgnoreCameraZoom, _godot_object, ignore); 166 } 167 /** 168 169 */ 170 bool isIgnoreCameraZoom() 171 { 172 checkClassBinding!(typeof(this))(); 173 return ptrcall!(bool)(_classBinding.isIgnoreCameraZoom, _godot_object); 174 } 175 /** 176 The ParallaxBackground's scroll value. Calculated automatically when using a $(D Camera2D), but can be used to manually manage scrolling when no camera is present. 177 */ 178 @property Vector2 scrollOffset() 179 { 180 return getScrollOffset(); 181 } 182 /// ditto 183 @property void scrollOffset(Vector2 v) 184 { 185 setScrollOffset(v); 186 } 187 /** 188 Base position offset of all $(D ParallaxLayer) children. 189 */ 190 @property Vector2 scrollBaseOffset() 191 { 192 return getScrollBaseOffset(); 193 } 194 /// ditto 195 @property void scrollBaseOffset(Vector2 v) 196 { 197 setScrollBaseOffset(v); 198 } 199 /** 200 Base motion scale of all $(D ParallaxLayer) children. 201 */ 202 @property Vector2 scrollBaseScale() 203 { 204 return getScrollBaseScale(); 205 } 206 /// ditto 207 @property void scrollBaseScale(Vector2 v) 208 { 209 setScrollBaseScale(v); 210 } 211 /** 212 Top left limits for scrolling to begin. If the camera is outside of this limit the background will stop scrolling. Must be lower than $(D scrollLimitEnd) to work. 213 */ 214 @property Vector2 scrollLimitBegin() 215 { 216 return getLimitBegin(); 217 } 218 /// ditto 219 @property void scrollLimitBegin(Vector2 v) 220 { 221 setLimitBegin(v); 222 } 223 /** 224 Right bottom limits for scrolling to end. If the camera is outside of this limit the background will stop scrolling. Must be higher than $(D scrollLimitBegin) to work. 225 */ 226 @property Vector2 scrollLimitEnd() 227 { 228 return getLimitEnd(); 229 } 230 /// ditto 231 @property void scrollLimitEnd(Vector2 v) 232 { 233 setLimitEnd(v); 234 } 235 /** 236 If `true` elements in $(D ParallaxLayer) child aren't affected by the zoom level of the camera. 237 */ 238 @property bool scrollIgnoreCameraZoom() 239 { 240 return isIgnoreCameraZoom(); 241 } 242 /// ditto 243 @property void scrollIgnoreCameraZoom(bool v) 244 { 245 setIgnoreCameraZoom(v); 246 } 247 }