File tree Expand file tree Collapse file tree 6 files changed +189
-146
lines changed
articles/tutorials/advanced/2d_shaders/06_color_swap_effect Expand file tree Collapse file tree 6 files changed +189
-146
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ private Texture2D _colorMap ;
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ public override void LoadContent()
6
6
_colorSwapMaterial = Core . SharedContent . WatchMaterial ( "effects/colorSwapEffect" ) ;
7
7
_colorSwapMaterial . IsDebugVisible = true ;
8
8
9
- var colorMap = Content . Load < Texture2D > ( "images/color-map-1" ) ;
10
- _colorSwapMaterial . SetParameter ( "ColorMap" , colorMap ) ;
9
+ _colorMap = Core . SharedContent . Load < Texture2D > ( "images/color-map-1" ) ;
10
+ _colorSwapMaterial . SetParameter ( "ColorMap" , _colorMap ) ;
11
11
}
Original file line number Diff line number Diff line change 1
- public override void Draw ( GameTime gameTime )
2
- {
3
- // ...
4
-
5
- Core . SpriteBatch . Begin (
6
- samplerState : SamplerState . PointClamp ,
7
- sortMode : SpriteSortMode . Immediate ,
8
- effect : _colorSwapMaterial . Effect ) ;
9
-
10
- // ...
11
- }
1
+ Core .SpriteBatch .Begin (
2
+ samplerState: SamplerState .PointClamp ,
3
+ sortMode: SpriteSortMode .Immediate ,
4
+ effect: _colorSwapMaterial.Effect );
Original file line number Diff line number Diff line change 1
1
public override void Draw ( GameTime gameTime )
2
2
{
3
- // Clear the back buffer.
4
- Core . GraphicsDevice . Clear ( Color . CornflowerBlue ) ;
5
-
6
- Core . SpriteBatch . Begin (
7
- samplerState : SamplerState . PointClamp ,
8
- sortMode : SpriteSortMode . Immediate ,
9
- effect : _colorSwapMaterial . Effect ) ;
3
+ // ...
10
4
11
5
// Update the colorMap
12
6
_colorSwapMaterial . SetParameter ( "ColorMap" , _colorMap ) ;
13
-
7
+
14
8
// Draw the tilemap
15
9
_tilemap . Draw ( Core . SpriteBatch ) ;
16
-
10
+
17
11
// Draw the bat.
18
12
_bat . Draw ( ) ;
19
13
20
14
// Update the colorMap for the slime
21
- _colorSwapMaterial . SetParameter ( "ColorMap" , _slimeColorMap . ColorMap ) ;
22
-
23
- // Draw the slime.
15
+ _colorSwapMaterial . SetParameter ( "ColorMap" , _slimeColorMap . ColorMap ) ;
16
+
17
+ // Draw the slime.
24
18
_slime . Draw ( ) ;
25
19
26
20
// Always end the sprite batch when finished.
Original file line number Diff line number Diff line change
1
+ public override void Update ( GameTime gameTime )
2
+ {
3
+ // ...
4
+
5
+ // Update the bat;
6
+ _bat . Update ( gameTime ) ;
7
+
8
+ // Perform collision checks
9
+ CollisionChecks ( gameTime ) ;
10
+ }
You can’t perform that action at this time.
0 commit comments