James Rackliffe
James Rackliffe

Reputation: 1

Corona adding collision and playing a sound

EDIT: Ignore most the below as the problem seems to be I don't have the "movieclip" module loaded according to the debugger... how in the hell do you load the movieclip or physics module I have wrote code for both and that is the issue. Is this module included? do I download it from somewhere? what gives?

I have the following code in Lua (corona specifically)

function scene:createScene( event )
    local group = self.view
    local bg = display.newImage("stage.png")
    local vio = display.newImage("vio.png")
    vio.x = 150
    vio.y = 180
    local b = display.newImage("b.png")
    b.x = -70
    b.y = 200
end

I need there to be a touch screen event so that dragging left or right moves object B left or right on the horizontal axis..and detects it crossing the center of the screen and plays an sound...

I found some code that would do this as a movieclip but the example code

local myAnim = movieclip.newAnim( b.png )
    local function pressFunction()
    myAnim.alpha = 0.7
end
local function releaseFunction()
    myAnim.alpha = 1
end
myAnim:setDrag()
    drag=true,
    onPress=pressFunction,
    onRelease=releaseFunction,
    bounds= { 50,200, 220, 200}
end

Also I added the local movieclip = requires (movieclip) at the top of my code and it removes all my background images and tabBar :(

Please help me figure this out I am new to Corona and Lua.

Upvotes: 0

Views: 394

Answers (2)

Rob Miracle
Rob Miracle

Reputation: 3063

Physics is part of the core Corona SDK API. You should not have to include any external files. Simply adding:

local physics = require("physics")

at the top of the module where you plan to use physics should suffice. As @speeder said, the movieclip.lua module has been deprecated in favor of using the new sprite sheets. Personally I loved using movieclip, but it's pretty wasteful on memory and isn't nearly as efficient or functional as sprite sheets.

Upvotes: 1

speeder
speeder

Reputation: 6296

Movieclip is a ancient thing...

It is a library, that used now deprecated and obsolete parts of the API.

I wonder even how you found it (I never had heard of it until seeing your question, and had to dig some forum skills to figure what it was).

So, yes, movieclip is a separate .lua file that you need to find and download. But I suggest you don't do that, since it uses things that don't exist anymore.

Upvotes: 0

Related Questions