20 Rotation - JcerelusDev/CanvasGameJs GitHub Wiki
How to use the rotate method
The rotate methode is used to rotate sprites like : a square, a sprite image and a spritesheet image.
It is devided into three methods :
1.- drawSpriteRot(angle,type)
2.- SpriteImgRot(angle,type)
3.- SpriteSheetRot(angle,type)
Good to know :
Don't use it on already drawn objects, because that method will automatically do the drawing for you. type can be normal or flat ,by default normal
Example with drawSpriteRot(0.3) :
considering we use the same game object
var square = new Sprite(40,150,32,32,10,10,"blue")
game.drawGame = function(){
square.drawSpriteRot(0.4,"flat")
}
Example with SpriteImgRot() :
considering we use the same game object
var player = new Sprite(40,150,32,32,10,10)
player.image.src="yourImage.png"
game.render = function(){
player.SpriteImgRot()
}
Example with SpriteSheetRot() :
considering we use the same game object
var player = new Sprite(0,2,96,96,40,150,32,32,10,10)
player.image.src="yourImage.png"
game.drawGame = function(){
player.drawSpriteSheetRot(0.3,"flat")
}