Sprite:spriteToLocal: Difference between revisions

From GiderosMobile
Created page with "'''Available since:''' Gideros 2023.2<br/> '''Class:''' Sprite<br/> === Description === Converts from one Sprite local space to another. <source lang="lua"> Sprite:sprite..."
 
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
=== Description ===
=== Description ===
Converts from one Sprite local space to another.
Converts from one Sprite local space to another.
<source lang="lua">
<syntaxhighlight lang="lua">
Sprite:spriteToLocal(spr,x,y,z,tx,ty,tz)
Sprite:spriteToLocal(spr,x,y,z,tx,ty,tz)
</source>
</syntaxhighlight>


=== Parameters ===
=== Parameters ===
Line 17: Line 17:
'''tz''': (number) the new z local space<br/>
'''tz''': (number) the new z local space<br/>


=== Exemple ===
=== Example ===
'''I am not sure this is a good example :-('''
'''I am not sure this is a good example :-('''
<source lang="lua">
<syntaxhighlight lang="lua">
-- event mouse enter example?
-- event mouse enter example?
local mypixel = Pixel.new(0xFF0000, 1, 64, 64)
local mypixel = Pixel.new(0xFF0000, 1, 64, 64)
Line 29: Line 29:
e:stopPropagation()
e:stopPropagation()
end)
end)
</source>
</syntaxhighlight>


{{Sprite}}
{{Sprite}}

Latest revision as of 17:49, 18 October 2025

Available since: Gideros 2023.2
Class: Sprite

Description

Converts from one Sprite local space to another.

Sprite:spriteToLocal(spr,x,y,z,tx,ty,tz)

Parameters

spr: (Sprite) target sprite local space
x: (number) original x local space
y: (number) original y local space
z: (number) original z local space
tx: (number) the new x local space
ty: (number) the new y local space
tz: (number) the new z local space

Example

I am not sure this is a good example :-(

-- event mouse enter example?
local mypixel = Pixel.new(0xFF0000, 1, 64, 64)
mypixel:setPosition(128, 128)
stage:addChild(mypixel)
mypixel:addEventListener(Event.MOUSE_ENTER, function(e)
	print("MOUSE_ENTER", e.x, e.y)
	print("MOUSE_ENTER mypixel:spriteToLocal", mypixel:spriteToLocal(stage, e.x, e.y, 0, mypixel:getPosition()))
	e:stopPropagation()
end)