VisualNEO Win Plugin Manual

neoCanvas 2.3 Manual

Plugin ID:com.visualneo.neocanvas
Version:2.3
Suite:VisualNEO UI & Data Suite (Commercial)
Publisher:SinLios
Category:Graphics / Drawing & Vector Canvas
Control:neo-canvas-display

Overview

neoCanvas is a native 2D canvas for VisualNEO Win. It combines sprites, sprite-sheet animation, vector drawing, particles, basic physics and collisions, keyboard input, and low-latency sound effects in one control. It is intended for arcade games, interactive diagrams, animated interfaces, and other frame-driven publications.

Rendering uses GDI+ antialiasing and an off-screen buffer. Sound effects use Windows DirectSound 8 and require no additional runtime DLL.

Properties

PropertyTypeDefaultPurpose
fpsinteger60Fixed simulation rate from 1 to 60 FPS.
physicsGravityYnumber0.0Vertical acceleration applied to sprites.
physicsFrictionnumber0.99Velocity multiplier applied by the scene.
enableClickSelectionbooleantrueEnables spriteclick.
keyboardEnabledbooleantrueEnables keyboard state and keyboard events.
autoFocusbooleantrueGives the canvas keyboard focus when clicked.
emitTickEventsbooleantrueEnables the frame tick event. Disable it when it is not needed.
tickEventFpsinteger10Limits NeoScript tick delivery independently from rendering FPS (1 to 60). Use a low rate for action-heavy game logic.
masterSfxVolumeinteger100Sound-effects volume from 0 to 100.
maxSoundVoicesinteger32Maximum simultaneous DirectSound voices, from 1 to 128.
bgColorcolor/stringautoCanvas background color, auto, or transparent.

The VisualNEO style panel also supplies the host fill, line color, line width, and Hollow state.

Keyboard And Game Loop

Click the canvas or call neoCanvasFocus before expecting keyboard input. Multiple keys remain active at the same time. The state is cleared automatically when the control loses focus, is disabled, is hidden, or is destroyed, preventing a movement key from becoming stuck.

Use keydown for discrete commands such as firing or opening a menu. Use neoCanvasIsKeyDown or the pressedKeys array during tick for continuous movement. This avoids depending on the Windows key-repeat delay.

tick supplies:

  • deltaTime: real elapsed time in seconds, capped after long pauses.
  • fixedDelta: stable simulation step, normally 1 / fps.
  • frame: monotonically increasing simulation frame number.
  • fps: configured target rate.

The engine performs at most five catch-up updates per timer message so a suspended page cannot produce an uncontrolled update burst.

Actions

Scene And Drawing

CommandParameters after object nameResult or purpose
neoCanvasClearnoneRemoves every sprite, shape, and particle.
neoCanvasSetBackgroundcolor or image pathSets a #HEX color, auto, transparent, or BMP image.
neoCanvasDrawLineX1, Y1, X2, Y2, color, widthAdds an antialiased line.
neoCanvasDrawCirclecenter X, center Y, radius, fill, strokeAdds a circle.
neoCanvasDrawTexttext, X, Y, font, size, colorAdds text.
neoCanvasDrawRectangleX, Y, width, height, fill, stroke, line width, corner radiusAdds a rectangle.
neoCanvasDrawEllipsecenter X, center Y, radius X, radius Y, fill, stroke, line widthAdds an ellipse.
neoCanvasDrawStarcenter X, center Y, points, outer radius, inner radius, fill, stroke, line widthAdds a star or regular polygon.
neoCanvasDrawPolylinepoint list, color, widthAdds a path such as 10,10,50,20,80,5.
neoCanvasDrawPointX, Y, color, radiusAdds a smooth point.
neoCanvasEmitParticlespreset, X, Y, count, optional colorsEmits confetti, fireworks, snow, rain, magic, fire, or explosion.
neoCanvasExportImageoutput pathSaves the rendered scene as PNG or BMP.
neoCanvasGetPixelX, Y, result variableReturns the rendered pixel as #RRGGBB.

Sprites And Collisions

CommandParameters after object nameResult or purpose
neoCanvasAddSpritesprite ID, BMP path, X, Y, width, heightAdds a sprite. The image path may be empty for an invisible collision entity.
neoCanvasAddAnimatedSpritesprite ID, sheet path, X, Y, frame width, frame height, frame count, FPSAdds a sprite-sheet animation.
neoCanvasMoveSpritesprite ID, X, Y, optional velocity X, velocity YSets position and optionally velocity.
neoCanvasRotateSpritesprite ID, degreesSets rotation.
neoCanvasScaleSpritesprite ID, scale X, scale YSets visual scale.
neoCanvasFlipSpritesprite ID, horizontal, verticalFlips the image.
neoCanvasSetSpriteAnimsprite ID, playing, frame, loopControls animation playback.
neoCanvasSetSpriteZIndexsprite ID, Z indexChanges draw order.
neoCanvasEnableSpriteDragsprite ID, enabledEnables pointer dragging.
neoCanvasSetSpriteSolidsprite ID, solid, restitutionEnables simple solid/bounce behavior.
neoCanvasSetSpriteVisiblesprite ID, visibleShows or hides a sprite without removing it. Hidden sprites do not collide.
neoCanvasSetSpriteGroupsprite ID, groupAdds a logical group to collision event data.
neoCanvasGetSpriteStatesprite ID, result variableReturns position, velocity, size, angle, visibility, group, frame, and playback state as JSON.
neoCanvasCheckCollisionsprite A, sprite B, result variableReturns True or False.
neoCanvasCheckGroupCollisionsprite ID, group, matching sprite variable, result variableTests one sprite against every visible sprite in a group and returns the first matching sprite ID plus True or False.
neoCanvasConsumeGroupCollisionsprite ID, group, matching sprite variable, result variableConsumes a native collision-start record retained since the previous logic tick. Fast contacts cannot pass unnoticed.
neoCanvasPointInSpritesprite ID, X, Y, result variableReturns True or False.
neoCanvasRemoveSpritesprite IDRemoves the sprite.

Input

CommandParameters after object nameResult or purpose
neoCanvasFocusnoneMoves keyboard focus to the canvas.
neoCanvasIsKeyDownkey name/code, result variableReturns True while that key is held. Names include Left, Right, Up, Down, Space, Enter, Escape, letters, digits, and F1 to F24.
neoCanvasConsumeKeyPresskey name/code, result variableReturns True once for each initial press retained by the native input queue, even if the key was released before NeoScript polls it.
neoCanvasGetInputStateresult variableReturns focused and the pressedKeys code array as JSON.

Sound Effects

CommandParameters after object nameResult or purpose
neoCanvasLoadSoundsound ID, WAV pathPreloads a PCM WAV file.
neoCanvasPlaySoundsound ID, volume, pan, pitch, loop, voice variableStarts a new simultaneous voice and returns an ID such as laser#3.
neoCanvasStopSoundsound or voice IDStops one voice or every voice using a sound ID; returns the count.
neoCanvasPauseSoundsound or voice IDPauses matching voices; returns the count.
neoCanvasResumeSoundsound or voice IDResumes matching voices; returns the count.
neoCanvasUnloadSoundsound IDStops matching voices and releases the preloaded asset.
neoCanvasStopAllSoundsnoneStops every voice on this canvas.
neoCanvasSetMasterVolume0 to 100Changes the volume of active and future voices.

Sound effects accept uncompressed PCM RIFF/WAV files. Convert MP3, AAC, floating-point WAV, and compressed WAV files to PCM WAV first. Each neoCanvasPlaySound call creates an independent voice, so repeated shots and impacts can overlap. Use neoAudio for music, streaming, and long-form playback.

Events

EventPayloadNotes
tickfps, deltaTime, fixedDelta, frameStable game-loop timing.
keydownkeyCode, key, repeat, modifiers, pressedKeysFires for initial press and Windows repeats.
keyupsame keyboard payloadFires on release.
inputchangekeyboard payload or reason: focusLostFires only when held-key state changes.
spriteclickspriteId, x, ySprite pointer click.
spritedragstartspriteId, x, yDrag begins.
spritedraggingspriteId, x, yDrag position changes.
spritedropspriteId, x, yDrag ends.
spritehoverenterspriteId, x, yPointer enters a sprite.
spritehoverleavespriteId, x, yPointer leaves a sprite.
collisionentersprite IDs and groupsFires once when a pair starts intersecting.
collisionexitsprite IDs and groupsFires once when a pair separates.
collisionsprite IDs and groupsCompatibility event; now fires once with collisionenter.
particleendempty objectFires when the active particle list becomes empty.
soundendsoundId, voiceIdFires when a non-looping voice completes naturally.

Minimal Game Pattern

TEXT
neoCanvasFocus "GameCanvas"
neoCanvasLoadSound "GameCanvas" "laser" "[PubDir]assets/laser.wav"
neoCanvasAddSprite "GameCanvas" "player" "[PubDir]assets/player.bmp" "140" "190" "32" "24"
neoCanvasSetSpriteGroup "GameCanvas" "player" "players"

In the tick event, query Left and Right with neoCanvasIsKeyDown, calculate the next X position, and call neoCanvasMoveSprite. In keydown, play the laser only when keyCode is 32 (Space) and repeat is false. Handle collisionenter to remove targets and play impact sounds.

Playable Sample

Open samples/neoCanvas-invaders-demo.pub to run a complete mini-game built with ordinary VisualNEO actions and one neoCanvas control. Its local assets folder contains all required BMP sprites and PCM WAV effects.

The sample demonstrates:

  • Native 60 FPS sprite movement for the player, invader formation, and projectile, while NeoScript gameplay is throttled to 6 tick events per second.
  • Simultaneous arrow-key, A/D, and Space state queried with neoCanvasIsKeyDown.
  • Native queued Space and R presses consumed exactly once, including short taps that begin and end between NeoScript ticks.
  • A fast eight-sprite formation whose native velocity is reversed at each edge, descends toward the player, and ends the round if it reaches the defensive line.
  • A reusable four-projectile pool with smooth native movement and queued group collisions through neoCanvasConsumeGroupCollision, preventing fast projectiles from tunneling between logic ticks.
  • Score and status variables displayed by ordinary VisualNEO text objects.
  • A live score and elapsed-time panel refreshed from NeoScript.
  • Dedicated game-over and victory screens with final score, completion time, particles, and sound.
  • Explosion and fireworks particles plus overlapping laser, hit, and victory effects.
  • Small, reusable NeoScript subroutines named ResetGame, MoveLeft, MoveRight, Fire, ProcessShot1 to ProcessShot4, and UpdateFleet.
  • Dot-prefixed NeoScript comments explaining scene setup, the projectile pool, movement, recycling, collisions, scoring, and final states.

Inspect the GameCanvas Actions panel to see the tick handler, including the R and Space key latches. Inspect the publication subroutines to see scene creation, movement, firing, hit processing, HUD refresh, final screens, and sound logic. The mouse buttons call the same movement, fire, and restart subroutines used by the keyboard path.

Deployment

Install the complete com.visualneo.neocanvas.vnplugin folder. The Win32 module is bin/win32-x86/neoCanvas.dll. No third-party DLL or audio codec package is required.