Solarus quests
1.6
Quest maker's reference
|
A path movement follows a specified path on an 8*8 pixels grid, in an 8-direction system. A path is a succession of steps of 8 pixels in one of the 8 main directions. You can define each step of the path and make it repeated if you want.
Path movements are particular movement objects. Therefore, they inherit all methods from the type movement.
See Methods of all movement types to know these methods.
The following methods are specific to path movements.
Returns the path of this movement.
Sets the path of this movement.
path
(table): The path as an array of integers. Each value is a number between 0 and 7 that represents a step (move of 8 pixels) in the path. 0 is East, 1 is North-East, etc.Example of use:
-- Example of code from a map script. -- Assume that there is an NPC called "scared_cat" on this map. function scared_cat:on_interaction() -- The hero is talking to me: run away! sol.audio.play_sound("meow") local movement = sol.movement.create("path") -- This path is arbitrary, it's just an example (North and then West). movement:set_path{2,2,2,2,2,2,4,4,4,4} movement:set_speed(80) self:start_movement(movement) end
Returns the speed of this movement.
Sets the speed of this movement.
speed
(number): The new speed in pixels per second.Returns whether this movement repeats itself once the end of the path is reached.
true
if the path repeats itself.Sets whether this movement repeats itself once the end of the path is reached.
loop
(boolean, optional): true
to make the path repeat itself. No value means true
.Returns whether this movement automatically snaps to the map grid the map entity that it controls.
The map grid is composed of squares of 8*8 pixels. All tiles are aligned to the grid. This property has no effect if there is no current map of if this movement is not attached to a map entity.
true
if this movement automatically snaps its map entity to the map grid.Sets whether this movement should automatically snap to the map grid the map entity that it controls.
The map grid is composed of squares of 8*8 pixels. All tiles are aligned to the grid. This property has no effect if there is no current map of if this movement is not attached to a map entity.
snap
(boolean, optional): true
to make this movement automatically snap its map entity to the map grid. No value means true
.Returns the angle of the current trajectory in radians.
East is 0
, North is math.pi / 2
, West is math.pi
, South is 3 * math.pi / 2
.
Path movements are particular movement objects. Therefore, they inherit all events from the type movement.
See Events of all movement types to know these events.