JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
UpdateModelview Class Reference

Public Member Functions

 UpdateModelview (std::function< void(float t, Mat3 &)>)
 Pass a function that gets the time the effect is in use and a reference to the Modelview so that it can update it.
 
Action step () override
 
void beginDraw () const override
 
void endDraw () const override
 
void updateModelview (Mat3 &modelview) const override
 Called before drawing the widget.
 

Additional Inherited Members

- Public Types inherited from Effect
enum class  Action : uint8_t { NONE , REMOVE_EFFECT , REMOVE_WIDGET }
 

Detailed Description

Definition at line 33 of file effects.hpp.

Inheritance diagram for UpdateModelview:
[legend]
Collaboration diagram for UpdateModelview:
[legend]

Constructor & Destructor Documentation

◆ UpdateModelview()

UpdateModelview ( std::function< void(float t, Mat3 &)> )
explicit

Pass a function that gets the time the effect is in use and a reference to the Modelview so that it can update it.

Wiggle effect example:

widget->addEffect<jngl::UpdateModelview>([](float t, jngl::Mat3& modelview) {
float effectIntensity = std::max(std::sin(t * 3), 0.f);
modelview.rotate(std::sin(t * 50) * 0.08 * effectIntensity)
.scale(1 + effectIntensity * 0.1);
});
3x3 matrix
Definition Mat3.hpp:18
Mat3 & scale(float factor)
Multiplies the matrix by a scaling matrix.
Mat3 & rotate(float radian)
Multiplies the matrix with a rotation matrix.
T max(T... args)
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.
T sin(T... args)

Member Function Documentation

◆ step()

Action step ( )
overridevirtual

Implements Effect.

◆ beginDraw()

void beginDraw ( ) const
overridevirtual

Implements Effect.

◆ endDraw()

void endDraw ( ) const
overridevirtual

Implements Effect.

◆ updateModelview()

void updateModelview ( Mat3 & modelview) const
overridevirtual

Called before drawing the widget.

Reimplemented from Effect.


The documentation for this class was generated from the following file: