Game::Collisions::UserData - Role for picking up movement to the AABB
package MyUserData; use base 'Game::Collisions::UserData'; sub new { ... } sub on_aabb_move { my ($self, $args) = @_; my $add_x = $args->{add_x}; my $add_y = $args->{add_y}; ... } package main; my $user_data = MyUserData->new; my $collide = Game::Collisions->new; my $box = $collide->make_aabb({ x => 0, y => 0, length => 1, height => 1, user_data => $user_data, }); # MyUserData instance is called from here $box->move({ add_x => 1, add_y => 3, });
Set an instance of this to the user_data on an AABB, and it will have its on_aabb_move() method called right after any movement.
user_data
on_aabb_move()
sub on_aabb_move { my ($self, $args) = @_; my $add_x = $args->{add_x}; my $add_y = $args->{add_y}; ... }
Is passed the add_x and add_y parameters that were passed when the AABB moved.
add_x
add_y
To install Game::Collisions, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::Collisions
CPAN shell
perl -MCPAN -e shell install Game::Collisions
For more information on module installation, please visit the detailed CPAN module installation guide.