Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

setSpriteSpeed()

Purpose

Set a sprites speed

Description

Set a sprites horizontal and vertical speed. This is the amount that the sprite is moved by in each axis when updatesprites is called

Syntax

setSpriteSpeed( sprite, speed )

setSpriteSpeed( sprite, xspeed, yspeed )

sprite.x_speed = xspeed; sprite.y_speed = yspeed

Arguments

sprite handle of the created sprite

speed amount to add to the x and y positions of the sprite at each updatesprites call { x, y }

xspeed amount to add to the x position of the sprite at each updatesprites call

yspeed amount to add to the y position of the sprite at each updatesprites call

Example

radians( true )  
image = loadImage( "Untied Games/Enemy small top C", false )
ship = createSprite()
setSpriteImage( ship, image )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( ship, lastpos )
setSpriteScale( ship, { 8, 8 } )

loop
    clear()
    c = controls( 0 )
    printAt( 0, 0, "Use left joystick to control sprite" )
    setSpriteSpeed( ship, { 600 * c.lx, -600 * c.ly } )
    curpos = getSpriteLocation( ship )
    if curpos != lastpos then
        setSpriteRotation( ship, -pi / 2 + atan2( curpos.y - lastpos.y, curpos.x - lastpos.x ) )
        lastpos = curpos
    endIf
    updateSprites()
    drawSprites()
    update()
repeat

Associated Commands

getSpriteSpeed()

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.