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.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.canvaslayer; 25 import godot.node; 26 /** 27 A node used to create a parallax scrolling background. 28 29 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). 30 */ 31 @GodotBaseClass struct ParallaxBackground 32 { 33 package(godot) enum string _GODOT_internal_name = "ParallaxBackground"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ CanvasLayer _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("_camera_moved") GodotMethod!(void, Transform2D, Vector2) _cameraMoved; 44 @GodotName("get_limit_begin") GodotMethod!(Vector2) getLimitBegin; 45 @GodotName("get_limit_end") GodotMethod!(Vector2) getLimitEnd; 46 @GodotName("get_scroll_base_offset") GodotMethod!(Vector2) getScrollBaseOffset; 47 @GodotName("get_scroll_base_scale") GodotMethod!(Vector2) getScrollBaseScale; 48 @GodotName("get_scroll_offset") GodotMethod!(Vector2) getScrollOffset; 49 @GodotName("is_ignore_camera_zoom") GodotMethod!(bool) isIgnoreCameraZoom; 50 @GodotName("set_ignore_camera_zoom") GodotMethod!(void, bool) setIgnoreCameraZoom; 51 @GodotName("set_limit_begin") GodotMethod!(void, Vector2) setLimitBegin; 52 @GodotName("set_limit_end") GodotMethod!(void, Vector2) setLimitEnd; 53 @GodotName("set_scroll_base_offset") GodotMethod!(void, Vector2) setScrollBaseOffset; 54 @GodotName("set_scroll_base_scale") GodotMethod!(void, Vector2) setScrollBaseScale; 55 @GodotName("set_scroll_offset") GodotMethod!(void, Vector2) setScrollOffset; 56 } 57 /// 58 pragma(inline, true) bool opEquals(in ParallaxBackground other) const 59 { return _godot_object.ptr is other._godot_object.ptr; } 60 /// 61 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 62 { _godot_object.ptr = n; return null; } 63 /// 64 pragma(inline, true) bool opEquals(typeof(null) n) const 65 { return _godot_object.ptr is n; } 66 /// 67 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 68 mixin baseCasts; 69 /// Construct a new instance of ParallaxBackground. 70 /// Note: use `memnew!ParallaxBackground` instead. 71 static ParallaxBackground _new() 72 { 73 static godot_class_constructor constructor; 74 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ParallaxBackground"); 75 if(constructor is null) return typeof(this).init; 76 return cast(ParallaxBackground)(constructor()); 77 } 78 @disable new(size_t s); 79 /** 80 81 */ 82 void _cameraMoved(in Transform2D arg0, in Vector2 arg1) 83 { 84 Array _GODOT_args = Array.make(); 85 _GODOT_args.append(arg0); 86 _GODOT_args.append(arg1); 87 String _GODOT_method_name = String("_camera_moved"); 88 this.callv(_GODOT_method_name, _GODOT_args); 89 } 90 /** 91 92 */ 93 Vector2 getLimitBegin() const 94 { 95 checkClassBinding!(typeof(this))(); 96 return ptrcall!(Vector2)(GDNativeClassBinding.getLimitBegin, _godot_object); 97 } 98 /** 99 100 */ 101 Vector2 getLimitEnd() const 102 { 103 checkClassBinding!(typeof(this))(); 104 return ptrcall!(Vector2)(GDNativeClassBinding.getLimitEnd, _godot_object); 105 } 106 /** 107 108 */ 109 Vector2 getScrollBaseOffset() const 110 { 111 checkClassBinding!(typeof(this))(); 112 return ptrcall!(Vector2)(GDNativeClassBinding.getScrollBaseOffset, _godot_object); 113 } 114 /** 115 116 */ 117 Vector2 getScrollBaseScale() const 118 { 119 checkClassBinding!(typeof(this))(); 120 return ptrcall!(Vector2)(GDNativeClassBinding.getScrollBaseScale, _godot_object); 121 } 122 /** 123 124 */ 125 Vector2 getScrollOffset() const 126 { 127 checkClassBinding!(typeof(this))(); 128 return ptrcall!(Vector2)(GDNativeClassBinding.getScrollOffset, _godot_object); 129 } 130 /** 131 132 */ 133 bool isIgnoreCameraZoom() 134 { 135 checkClassBinding!(typeof(this))(); 136 return ptrcall!(bool)(GDNativeClassBinding.isIgnoreCameraZoom, _godot_object); 137 } 138 /** 139 140 */ 141 void setIgnoreCameraZoom(in bool ignore) 142 { 143 checkClassBinding!(typeof(this))(); 144 ptrcall!(void)(GDNativeClassBinding.setIgnoreCameraZoom, _godot_object, ignore); 145 } 146 /** 147 148 */ 149 void setLimitBegin(in Vector2 ofs) 150 { 151 checkClassBinding!(typeof(this))(); 152 ptrcall!(void)(GDNativeClassBinding.setLimitBegin, _godot_object, ofs); 153 } 154 /** 155 156 */ 157 void setLimitEnd(in Vector2 ofs) 158 { 159 checkClassBinding!(typeof(this))(); 160 ptrcall!(void)(GDNativeClassBinding.setLimitEnd, _godot_object, ofs); 161 } 162 /** 163 164 */ 165 void setScrollBaseOffset(in Vector2 ofs) 166 { 167 checkClassBinding!(typeof(this))(); 168 ptrcall!(void)(GDNativeClassBinding.setScrollBaseOffset, _godot_object, ofs); 169 } 170 /** 171 172 */ 173 void setScrollBaseScale(in Vector2 scale) 174 { 175 checkClassBinding!(typeof(this))(); 176 ptrcall!(void)(GDNativeClassBinding.setScrollBaseScale, _godot_object, scale); 177 } 178 /** 179 180 */ 181 void setScrollOffset(in Vector2 ofs) 182 { 183 checkClassBinding!(typeof(this))(); 184 ptrcall!(void)(GDNativeClassBinding.setScrollOffset, _godot_object, ofs); 185 } 186 /** 187 The base position offset for all $(D ParallaxLayer) children. 188 */ 189 @property Vector2 scrollBaseOffset() 190 { 191 return getScrollBaseOffset(); 192 } 193 /// ditto 194 @property void scrollBaseOffset(Vector2 v) 195 { 196 setScrollBaseOffset(v); 197 } 198 /** 199 The base motion scale for all $(D ParallaxLayer) children. 200 */ 201 @property Vector2 scrollBaseScale() 202 { 203 return getScrollBaseScale(); 204 } 205 /// ditto 206 @property void scrollBaseScale(Vector2 v) 207 { 208 setScrollBaseScale(v); 209 } 210 /** 211 If `true`, elements in $(D ParallaxLayer) child aren't affected by the zoom level of the camera. 212 */ 213 @property bool scrollIgnoreCameraZoom() 214 { 215 return isIgnoreCameraZoom(); 216 } 217 /// ditto 218 @property void scrollIgnoreCameraZoom(bool v) 219 { 220 setIgnoreCameraZoom(v); 221 } 222 /** 223 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. 224 */ 225 @property Vector2 scrollLimitBegin() 226 { 227 return getLimitBegin(); 228 } 229 /// ditto 230 @property void scrollLimitBegin(Vector2 v) 231 { 232 setLimitBegin(v); 233 } 234 /** 235 Bottom-right 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. 236 */ 237 @property Vector2 scrollLimitEnd() 238 { 239 return getLimitEnd(); 240 } 241 /// ditto 242 @property void scrollLimitEnd(Vector2 v) 243 { 244 setLimitEnd(v); 245 } 246 /** 247 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. 248 */ 249 @property Vector2 scrollOffset() 250 { 251 return getScrollOffset(); 252 } 253 /// ditto 254 @property void scrollOffset(Vector2 v) 255 { 256 setScrollOffset(v); 257 } 258 }