Masking an image resizes the object

We’re working diligently on a game here at my office. For some odd reason the sales person decided to set up a meeting with a major company tomorrow and one of our “ins” will be our game, which isn’t complete by far. Which … is infuriating.

So, I’m up against a clock and I have no solution to this problem.

I’m using Peach Pellen’s excellent time bar tutorial … well, a hacked version but it’s a version of it none the less.

What we’re doing is this - it’s a bomb. The fuse is actually the timer. I have a spark that’s counting down. I want a mask to hide the fuse as the timer counts down - basically following the spark.

Problem occurs.

I set the mask, no prob I get that. Mask hides the WHOLE fuse. Ok, that’s annoying. I change the image.maskX and it not only changes the maskX but it changes the image scale …

I’ve gone through the Flashlight example, which really doesn’t help sadly.

Help me Obi-Wan … I mean, Corona Community. You’re my only hope!

  
local bombNeutral = display.newImage (imgPath .. "bombBottom.png")  
bombNeutral.x = display.contentWidth -41  
bombNeutral.y = display.contentHeight -65  
  
local bombGlowy = display.newImage (imgPath .."bombBottom\_red.png")  
bombGlowy.x = display.contentWidth -41  
bombGlowy.y = display.contentHeight -65  
  
local fuseImage = display.newImage (imgPath .. "fuse.png", 996,25)  
fuseImage.x = display.contentWidth \*.5  
fuseImage.y = display.contentHeight - 53  
  
local fuseImageMask = graphics.newMask(imgPath .. "blackmask3.png")  
fuseImage:setMask (fuseImageMask)  
fuseImage.maskX = fuseImage.maskX - 200  
  
local function loseTime()  
  
 if timeBar.width == 750 then  
 transition.to(bombNeutral, {time=3000,alpha=0})  
  
 end  
 if (timeBar.width == nil or timeBar.width \>= 900 ) then  
 bombBursting:show(bombGlowy.x, bombGlowy.y)  
 bombBursting:playClip("mExplode")  
 displayGameOver()  
  
 else  
 timeBar.width = timeBar.width + timerSpeedVar  
 fuseSpark:translate(timerSpeedVar,0)  
 createSpark()  
 sparkXloc = sparkXloc + timerSpeedVar   
 timeBar:setReferencePoint(display.BottomLeftReferencePoint)   
 timeBar.X = 20  
  
 end  
end  
  
gameTimer = timer.performWithDelay(1,loseTime, 0)  
  

timer.width is being controlled by an image. For some reason I never changed that from an example I used … sorry for my hackiness here.

I need help … major help. [import]uid: 97023 topic_id: 21491 reply_id: 321491[/import]

Would there be any chance of you uploading a zip so I (or others) could download and run this? (You could make a small example showing this if you didn’t want to upload the whole thing, I don’t know how big it is, etc.)

I ask because by running this I’m guessing I, or someone else, might be able to give you some solid help - whereas just looking at the code it’s not so easy.

Peach :slight_smile:

PS - Thanks for pimping Techority :wink: [import]uid: 52491 topic_id: 21491 reply_id: 85143[/import]

Well. I can’t actually send the code at this point. Managers are a bit NDA on what we’ve worked on and when I asked them about posting the code to get community to look and trouble shoot you would have though I told them I ran over their favorite chicken named Peppers …

A screen grab of the fuse area is here:
http://www.screencast.com/t/senp9dohZt

I can probably chat with you, Peach, via Skype or other means if you are willing to help.

If anyone can even.

Thanks! [import]uid: 97023 topic_id: 21491 reply_id: 85205[/import]

Well, Peach, I ended up emailing you. Hope what I sent isn’t laughably bad coding … [import]uid: 97023 topic_id: 21491 reply_id: 85236[/import]

Damn, that’s a beautiful graphic!

I haven’t checked my email in a little but will get to yours tonight or tomorrow. (It’s past 5am here now so I’m scared to open my inbox. Last time I did that I didn’t get to bed until 11am ;))

Don’t worry about the coding, if it works and isn’t throwing errors it’s good work :wink: No judgements here.

You’ll hear from me later.

Peach :slight_smile: [import]uid: 52491 topic_id: 21491 reply_id: 85277[/import]

oohhh thanks a ton Peach for all your help in getting this resolved! You’re amazing!!

For those who are in the same pinch, this is the code that the Awesome One gave me to fix my issues:

  
local bombNeutral = display.newImage (imgPath .. "bombBottom.png")  
bombNeutral.x = display.contentWidth -41  
bombNeutral.y = display.contentHeight -65  
  
local bombGlowy = display.newImage (imgPath .."bombBottom\_red.png")  
bombGlowy.x = display.contentWidth -41  
bombGlowy.y = display.contentHeight -65  
  
fuseImageVar = -450  
--PEACH  
local fuseImageM = graphics.newMask (imgPath .. "fuseMask.png", fuseImageVar, 680)  
  
local fuseImage = display.newImage (imgPath .. "fuse.png", 996,25)  
fuseImage.x = display.contentWidth \*.5  
fuseImage.y = display.contentHeight - 53  
  
fuseImage:setMask (fuseImageM)  
  
local function moveMask()  
 fuseImage.maskX = fuseSpark.x - 30  
end  
Runtime:addEventListener("enterFrame", moveMask)  
--END PEACH  
  
local function loseTime()  
  
 if timeBar.width == 750 then  
 transition.to(bombNeutral, {time=3000,alpha=0})  
  
 end  
 if (timeBar.width == nil or timeBar.width \>= 900 ) then  
 bombBursting:show(bombGlowy.x, bombGlowy.y)  
 bombBursting:playClip("mExplode")  
 displayGameOver()  
  
 else  
 timeBar.width = timeBar.width + timerSpeedVar  
 fuseSpark:translate(timerSpeedVar,0)  
 fuseImageVar = fuseImageVar + timerSpeedVar  
 createSpark()  
 sparkXloc = sparkXloc + timerSpeedVar   
 timeBar:setReferencePoint(display.BottomLeftReferencePoint)   
 timeBar.X = 20  
  
 end  
end  
  
gameTimer = timer.performWithDelay(1,loseTime, 0)  
local gameTimerRunning = true  

Then, where the game ending code is put the following:

Runtime:removeEventListener("enterFrame", moveMask)   

Thanks for the brilliant fix, Peach! [import]uid: 97023 topic_id: 21491 reply_id: 85572[/import]

No worries - best of luck with the project; the art really is spectacular :slight_smile: [import]uid: 52491 topic_id: 21491 reply_id: 85598[/import]