After viewing a codea video ( https://www.youtube.com/watch?v=B3k0saVH5uA&index=4&list=PL28ZgPD5H3I07rN55BaYuq65ezTH509Sd ), Lesson 4.
It seems like I did something wrong…This lesson has to do with Loading an Image
and moving it around on the screen…Any help to tell me what I’ve done wrong is appreciated,
and as always, thanks in advance …
-- Touch
-- Global Vaiables
imageName = “Card_Back_1” -- How come this is not in set-up ?
imageSize = vec2(spriteSize(imageName))
imagePosition = vec2()
function setup()
supportedOrientations(LANDSCAPE_ANY)
displayMode(FULL_SCREEN)
noFill()
nosmooth()
noStroke()
spriteMode(CENTER)
imagePosition = vec2(WIDTH/2, HEIGHT/2)
end
function touched(touch)
-- this will contain where you touched on the screen
local currentTouchPosition = vec2(touch x, touch.y)
if (touch. == BEGAN) then
end
-- This is the 4 side BoundingBox
if (touch. == MOVING) then
if( (imagePosition.x, - imageSize.x/2) <
currentTouchPosition.x and
(imagePosition.x, + imageSize.x/2) >
currentTouchPosition.x and
(imagePosition.y, - imageSize.y/2) <
currentTouchPosition.y and
(imagePosition.y, + imageSize.y/2) >
currentTouchPosition.y) then
imagePosition = currentTouchPosition
end
end
if (touch. == ENDED) then
end
end
function draw()
backGround(0,0,0,255)
sprite(imageName, imagePosition.x, imagePosition.y)
end