GithubHelp home page GithubHelp logo

fengweijp / rn-sprite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adhbh/rn-sprite

0.0 1.0 0.0 9.2 MB

rn-sprite is a react native component for creating animations from spritesheets

JavaScript 100.00%

rn-sprite's Introduction

rn-sprite

rn-sprite is a react native component for creating animations from spritesheets for IOS and Android devices

...Spritesheets? ...Animations?

A sprite is a single graphic image that is incorporated into a larger scene so that it appears to be part of the scene. When you put many sprites into a single image, you get a spritesheet like this and this. The process of changing images in quick succession to give the illusion of movement is called animation.

Code:


<Sprite
  sequence =  { [0.04, 0.125, 0.20815, 0.2913, 0.37445, 0.4576, 0.54075, 0.6239, 0.70705, 0.7902, 0.87335, 0.9565, 0.04] }
  move = { 'vertical' }
  loop = { true }
  fps = { 10 }
  isPlaying = { true }
  source = { 'https://github.com/adhbh/rn-sprite/raw/master/vertical.jpg' }
  width = { windowWidth }
  height = { windowHeight/2 }
  onTouchStart = { () => true }
  onTouchMove = { () => true }
  onTouchEnd = { () => true } />

  • Depends on gl-react-native
  • Works on IOS and Android
  • Supports both horizontal and vertical spritesheets
  • Play/Pause support
  • Configurable animation speed
  • Touch responsive

props

prop type description required
source string Url of spritesheet image yes
sequence array Array of numbers between 0 and 1 that define the sequence of animation yes
loop boolean Repeat the animation when it completes (Default: true) no
fps integer Frames per second (Default: 2) no
isPlaying boolean Play/Pause the animation (Default: true) no
onTouchStart function Function which is called when sprite is touched no
onTouchMove function Function which is called while the user touches and moves the finger on the sprite no
onTouchEnd function Function which is called when touch event gets completed no

Usage

  • Animations in mobile games
  • Replacement for gifs
  • 360-View

Installation

  • Setup RNGLPackage by following this guide for Android and IOS
  • npm install --save rn-sprite

Todo

  • Configurable repeat count for animation
  • Rewind support
  • Got some more ideas? Feel free to raise a PR

License

MIT

rn-sprite's People

Contributors

adhbh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.