-
Notifications
You must be signed in to change notification settings - Fork 4
2. Objects
This page shows the basic usage of objects and what you can do with them.
Objects can be created using the following syntax.
new Note({ time: 4 })This creates a new note with a time value of 4.
You can add properties to it, such as
track: "trackName". Properties are added using objects in the following way.new Note({ time: 4, x: 2 }, { track: "trackName", scale: [6.9, 1, 1] }, { dissolve: [ [0, 0], [1, 0.125, ease.Out.Cubic] ] })An object is pushed by calling the
push()method. Like so.new Note({ time: 4, x: 2 }, { track: "trackName", scale: [6.9, 1, 1] }).push();This is the base syntax for all objects/events.
These properties are supported by both notes and walls.
time: numberAssigns the object's time value.x: 0-3assigns the object'sxvalue or line index.
track: string|string[]Assigns the object's track.color: vec4Assigns the object's color.x: 0-3)Assigns the object's.position: vec2Overrides the object's position.rotation: vec3Assigns the object's rotation.localRotation: vec3Assigns the object's localRotation.scale: vec3Assigns the object's scale.njs: numberAssigns the object's NJS.offset: numberAssigns the object's offset.fake: booleanSets whether the object is fake or not.interactable: numberSets whether the object is interactable or not.
position: vec3animAssigns the object's position animation.definitePosition: vec3animAssigns the object's definitePosition animation.rotation: vec3animAssigns the object's rotation animation.localRotation: vec3animAssigns the object's localRotation animation.scale: vec3animAssigns the object's scale animation.color: vec4animAssigns the object's color animation.interactable: vec1animAssigns the object's interactable animation.dissolve: vec1animAssigns the object's dissolve animation.dissolveArrow: vec1animAssigns the object's dissolveArrow animation.
Notes are created with the following.
new Note(time)Or you can also use the
notesnippet to create the entire structure instantly.
time: numberAssigns the note's time.direction: 0-8Assigns the note's cutDirection.x: 0-2Assigns the note's lineLayer.y: 0-2Assigns the note's lineIndex.type: 0, 1, 3Assigns the note's type.
flip: vec2Assigns the note's flip animation.disableNoteGravity: booleanDisables the notes's gravity animation.disableSpawnEffect: booleanDisables the notes's spawn flash effect.disableNoteLook: booleanDisables the notes's rotation relative to the player.
Walls are created with the following.
new Wall(time)Or you can also use the
wallsnippet to create the entire structure instantly.
duration: numberSets the duration of the wall.
You can edit objects by filtering them out first, the syntax for selecting notes between time values
8and16would be.filter(notes, 8, 16);This selects all notes and allows you to edit them
You can also filter other types of stuff. Here's a list of everything you can filter:
notesFilters notes.wallsFilters walls.eventsFilters customEvents.lightsFilters light events.bombsFilters bombs. (V3 only)You can also add parameters to filters. These parameters are
typeanddirection.The code below would target all red notes between times
69and420that are facing down.filter(notes, 69, 420, { type: Note.Type.Red, direction: Note.Direction.Down });Yes, it is a bit long syntax but at least it's all in one function.
To add a track to an object, you would use this syntax.
track(filter(notes, 8, 16), ["deez", "nuts"]);That would add the tracks
deezandnutsto all notes between8and16.Once you've filtered your notes, you can start adding custom data to them like this.
filter(notes, 8, 16).forEach((n: NOTE) => { n.data.disableNoteGravity = true; })The syntax above would make all notes between
8and16not have the note jump gravity effect.Animations work in a similar way.
filter(notes, 8, 16).forEach((n: NOTE) => { n.anim.position = [ [0, 5, 0, 0], [0, 0, 0, 0.45, ease.Out.Circ] ]; })This makes all the notes spawn 5 units above normal and gradually come down to the player.
It is very much recommended to use variables when editing a lot of values to prevent messy and long code.
For example:
filter(notes, 8, 16).forEach((n: NOTE) => { n.data.fake = true; n.data.interactable = false; n.data.disableNoteGravity = true; n.data.disableSpawnEffect = true; n.data.disableNoteLook = true; })Can be shortened to
filter(notes, 8, 16).forEach((n: NOTE) => { const d = n.data; d.fake = true; d.interactable = false; d.disableNoteGravity = true; d.disableSpawnEffect = true; d.disableNoteLook = true; })This way, you don't have to type
n.databefore the actual property, but instead just dod.
Functions
- Note Effects
- Wall Effects
- Other Effects